24 package org.lightjason.agentspeak.action.builtin.math.blas.matrix;
26 import cern.colt.matrix.tdouble.impl.DenseDoubleMatrix2D;
27 import cern.colt.matrix.tdouble.impl.SparseDoubleMatrix2D;
38 import javax.annotation.Nonnegative;
39 import javax.annotation.Nonnull;
40 import java.util.ArrayList;
41 import java.util.Arrays;
42 import java.util.List;
43 import java.util.stream.Collectors;
44 import java.util.stream.IntStream;
82 @Nonnull
final List<ITerm> p_argument, @Nonnull
final List<ITerm> p_return )
84 final List<ITerm> l_arguments =
CCommon.
flatten( p_argument ).collect( Collectors.toList() );
88 && (
EType.
exists( l_arguments.get( l_arguments.size() - 1 ).<String>raw() ) ) )
90 l_type =
EType.
from( l_arguments.get( l_arguments.size() - 1 ).<String>raw() );
91 l_limit = l_arguments.size() - 1;
96 l_limit = l_arguments.size();
106 .map(
ITerm::<String>raw )
108 .map( DenseDoubleMatrix2D::new )
110 .forEach( p_return::add );
117 .map(
ITerm::<String>raw )
119 .map( SparseDoubleMatrix2D::new )
121 .forEach( p_return::add );
139 private static double[][]
parse( @Nonnull
final String p_string, @Nonnull
final IContext p_context )
141 final String[] l_rows = p_string.split(
";" );
142 final List<List<Double>> l_matrix =
new ArrayList<>();
144 final double[][] l_return =
new double[l_rows.length][
145 Arrays.stream( l_rows )
146 .map( i -> Arrays.stream( i.trim().split(
",|\\s" ) )
148 .filter( j -> !j.isEmpty() )
149 .mapToDouble( Double::parseDouble )
151 .collect( Collectors.toList() )
162 IntStream.range( 0, l_return.length )
164 .forEach( i -> IntStream.range( 0, l_return[i].length )
166 .forEach( j -> l_return[i][j] = l_matrix.get( i ).get( j ) ) );
base class of build-in actions for setting name by package/classname (without prefix character) ...
static boolean exists(final String p_name)
check method to check if a enum value with a name exists
creates a dense- or sparse-matrix from a string.
final int minimalArgumentNumber()
minimum number of arguments
static< N > IFuzzyValue< N > from( @Nonnull final N p_value)
factory
common structure for execution definition
execution context with local data
static Stream< ITerm > flatten( @Nonnull final Collection<? extends ITerm > p_terms)
flat term-in-term collection into a straight term list
static final long serialVersionUID
serial id
static< T > boolean rawvalueAssignableTo( @Nonnull final T p_value, @Nonnull final Class<?>... p_class)
checks a term value for assignable class
result for an immutable fuzzy value
static EType from(final String p_name)
additional factory
static< N > CRawTerm< N > from(final N p_value)
factory for a raw term
final IFuzzyValue< Boolean > execute(final boolean p_parallel, @Nonnull final IContext p_context, @Nonnull final List< ITerm > p_argument, @Nonnull final List< ITerm > p_return)
defines a plan-body operation
static double [][] parse( @Nonnull final String p_string, @Nonnull final IContext p_context)
parse the string in a list of lists with doubles
term structure for simple datatypes