24 package org.lightjason.agentspeak.action.builtin.math.bit.matrix;
26 import cern.colt.matrix.tbit.BitMatrix;
27 import cern.colt.matrix.tdouble.DoubleMatrix2D;
28 import cern.colt.matrix.tdouble.impl.DenseDoubleMatrix2D;
29 import cern.colt.matrix.tdouble.impl.SparseDoubleMatrix2D;
39 import javax.annotation.Nonnegative;
40 import javax.annotation.Nonnull;
41 import java.util.List;
42 import java.util.stream.Collectors;
43 import java.util.stream.IntStream;
80 @Nonnull
final List<ITerm> p_argument, @Nonnull
final List<ITerm> p_return )
82 final List<ITerm> l_arguments =
CCommon.
flatten( p_argument ).collect( Collectors.toList() );
83 final EType l_type = l_arguments.parallelStream()
85 .findFirst().map( i ->
EType.
from( i.<String>raw() ) )
93 .map(
ITerm::<BitMatrix>raw )
94 .map( i ->
CToBlas.
tomatrix( i,
new DenseDoubleMatrix2D( i.rows(), i.columns() ) ) )
96 .forEach( p_return::add );
104 .map(
ITerm::<BitMatrix>raw )
105 .map( i ->
CToBlas.
tomatrix( i,
new SparseDoubleMatrix2D( i.rows(), i.columns() ) ) )
107 .forEach( p_return::add );
126 private static DoubleMatrix2D
tomatrix( @Nonnull
final BitMatrix p_source, @Nonnull
final DoubleMatrix2D p_target )
128 IntStream.range( 0, p_source.rows() )
129 .forEach( r -> IntStream.range( 0, p_source.columns() ).forEach( c -> p_target.setQuick( r, c, p_source.getQuick( r, c ) ? 1 : 0 ) ) );
base class of build-in actions for setting name by package/classname (without prefix character) ...
converts the bit matrix to a blas matrix.
static< N > IFuzzyValue< N > from( @Nonnull final N p_value)
factory
common structure for execution definition
static final long serialVersionUID
serial id
final int minimalArgumentNumber()
minimum number of arguments
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
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< 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 DoubleMatrix2D tomatrix( @Nonnull final BitMatrix p_source, @Nonnull final DoubleMatrix2D p_target)
converts the bit matrix to the blas matrix
static EType from(final String p_name)
additional factory
static< N > CRawTerm< N > from(final N p_value)
factory for a raw term
term structure for simple datatypes