Class DenseConcat
java.lang.Object
org.flag4j.linalg.ops.dense.DenseConcat
This utility class provides implementations for the concatenation of dense tensors.
-
Method Details
-
concat
Concatenates two arrays and stores the result indest
.- Parameters:
src1
- First array in the concatenation.src2
- Second array in the concatenation.dest
- The array to store the array concatenation in. May benull
. If not null, must be at least as large assrc1.length + src2.length
.- Returns:
- If
dest != null
a reference todest
is returned. Otherwise, a new array is created and returned. - Throws:
IllegalArgumentException
- Ifdest != null && dest.length < (src1.length + src2.length)
.
-
repeat
Repeats a vectorn
times along a certain axis to create a matrix.- Parameters:
src
- Source array to repeat.n
- Number of times to repeat the array.axis
- Axis along which to repeat array:- If
axis=0
, then the vector will be treated as a row vector and stacked verticallyn
times. - If
axis=1
then the vector will be treated as a column vector and stacked horizontallyn
times.
- If
dest
- The array to store the array repeatedsrc
array in. May benull
. If not null, must be at least as large assrc1.length + src2.length
.- Returns:
- If
dest != null
a reference todest
is returned. Otherwise, a new array is created and returned. - Throws:
IllegalArgumentException
- Ifdest != null && dest.length < (src1.length + src2.length)
.
-
stack
Stacks two vectors along specified axis.
Stacking two vectors of length
n
along axis 0 stacks the vectors as if they were row vectors resulting in a2×n
matrix.Stacking two vectors of length
n
along axis 1 stacks the vectors as if they were column vectors resulting in an×2
matrix.- Parameters:
src1
- Entries of the first vector. Must be the same size assrc2
.src2
- Entries of the second vector. Must be the same size assrc1
.axis
- Axis along which to stack vectors. Must be 1 or 0.- If
axis=0
, then vectors are stacked as if they are row vectors. - If
axis=1
, then vectors are stacked as if they are column vectors.
- If
dest
- Array to store the stacked vectors in. May benull
. If notnull
, must be at least as large as the sum of the src array lengths.- Returns:
- If
dest != null
a reference todest
is returned. Otherwise, a new array is created and returned. - Throws:
IllegalArgumentException
- Ifsrc1.length != src2.length
.IllegalArgumentException
- If axis is not either 0 or 1.IllegalArgumentException
- Ifdest != null
anddest.length < src1.length + src2.length
.
-