Class ComplexNDArraySliceView<T extends Number>
- java.lang.Object
-
- io.github.hakkelt.ndarrays.internal.AbstractNDArray<T,T2>
-
- io.github.hakkelt.ndarrays.internal.AbstractNDArrayView<T,T2>
-
- io.github.hakkelt.ndarrays.internal.AbstractNDArraySliceView<org.apache.commons.math3.complex.Complex,T>
-
- io.github.hakkelt.ndarrays.internal.ComplexNDArraySliceView<T>
-
- All Implemented Interfaces:
ComplexNDArray<T>,NDArray<org.apache.commons.math3.complex.Complex>,Iterable<org.apache.commons.math3.complex.Complex>
public class ComplexNDArraySliceView<T extends Number> extends AbstractNDArraySliceView<org.apache.commons.math3.complex.Complex,T> implements ComplexNDArray<T>
A view for a ComplexNDArray that slices the parent ComplexNDArray. When slice(...) is called for a ComplexNDArray, an instance of this class is returned.
-
-
Constructor Summary
Constructors Constructor Description ComplexNDArraySliceView(NDArray<org.apache.commons.math3.complex.Complex> parent, Range[] slicingExpressions)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description NDArray<T>abs()Returns a new array holding the magnitude / absolute values of the elements.ComplexNDArray<T>apply(UnaryOperator<org.apache.commons.math3.complex.Complex> func)Apply the given function to each element of the array, and override each entry with the calculated new values.ComplexNDArray<T>applyOnComplexSlices(BiFunction<ComplexNDArray<T>,int[],NDArray<?>> func, int... iterationDims)Apply the given function to each slices of the array, and override each entry with the returned slice.ComplexNDArray<T>applyWithCartesianIndices(BiFunction<org.apache.commons.math3.complex.Complex,int[],org.apache.commons.math3.complex.Complex> func)Apply the given function to each element of the array, and override each entry with the calculated new values.ComplexNDArray<T>applyWithLinearIndices(BiFunction<org.apache.commons.math3.complex.Complex,Integer,org.apache.commons.math3.complex.Complex> func)Apply the given function to each element of the array, and override each entry with the calculated new values.NDArray<T>argument()Returns a new array holding the argument / argument of the elements.ComplexNDArray<T>copy()Returns a copy of this NDArray.ComplexNDArray<T>fillUsingCartesianIndices(Function<int[],org.apache.commons.math3.complex.Complex> func)Apply the given function to each element of the array, and override each entry with the calculated new values.ComplexNDArray<T>fillUsingLinearIndices(IntFunction<org.apache.commons.math3.complex.Complex> func)Apply the given function to each element of the array, and override each entry with the calculated new values.NDArray<T>imaginary()Returns a new array holding the imaginary part of the arrayComplexNDArray<T>mapOnComplexSlices(BiFunction<ComplexNDArray<T>,int[],NDArray<?>> func, int... iterationDims)Apply the given function to each slices of the array, and create a new NDArray with the calculated new values.NDArray<T>real()Returns a new array holding the real part of the arrayComplexNDArray<T>reduceComplexSlices(BiFunction<ComplexNDArray<T>,int[],org.apache.commons.math3.complex.Complex> func, int... iterationDims)Reduces slices along the specified dimensions in this NDArray to scalar values, reducing the number of dimensions.voidset(Number value, int linearIndex)Sets the value of an element specified by linear indexing.voidset(Number value, int... indices)Sets the value of an element specified by cartesian indexing.voidsetImag(Number value, int linearIndex)Sets the imaginary part of an element specified by linear indexing.voidsetImag(Number value, int... indices)Sets the imaginary part of an element specified by cartesian indexing.voidsetReal(Number value, int linearIndex)Sets the real part of an element specified by linear indexing.voidsetReal(Number value, int... indices)Sets the real part of an element specified by cartesian indexing.ComplexNDArray<T>similar()Returns a new array of the same shape as this NDArray filled with zeros.-
Methods inherited from class io.github.hakkelt.ndarrays.internal.AbstractNDArraySliceView
applyOnSlices, equals, hashCode, mapOnSlices
-
Methods inherited from class io.github.hakkelt.ndarrays.internal.AbstractNDArrayView
dataTypeAsString, dtype, dtype2, getNamePrefix, getParent, getTopMostParent, linearIndexToViewIndices
-
Methods inherited from class io.github.hakkelt.ndarrays.internal.AbstractNDArray
accumulate, contains, contentToString, contentToString, forEach, forEachWithCartesianIndices, forEachWithLinearIndices, get, get, getImag, getImag, getReal, getReal, iterator, length, maybeParallelStream, ndim, norm, norm, parallelStream, prod, reduceSlices, set, set, shape, shape, spliterator, stream, streamCartesianIndices, streamLinearIndices, sum, toArray, toArray, toArray, toString, writeToFile
-
Methods inherited from interface io.github.hakkelt.ndarrays.ComplexNDArray
accumulate, add, add, add, add, add, add, add, add, addInplace, addInplace, addInplace, addInplace, addInplace, addInplace, addInplace, addInplace, concatenate, contentToString, copyFrom, copyFrom, copyFrom, copyFrom, copyFrom, copyFrom, copyFrom, copyFrom, copyFrom, copyFrom, copyFrom, copyFrom, copyFrom, copyFrom, copyFrom, copyFrom, divide, divide, divide, divide, divide, divide, divide, divide, divideInplace, divideInplace, divideInplace, divideInplace, divideInplace, divideInplace, divideInplace, divideInplace, dropDims, dtype2, fill, fill, fill, getImag, getImag, getReal, getReal, inverseMask, map, mapWithCartesianIndices, mapWithLinearIndices, mask, mask, maskWithCartesianIndices, maskWithLinearIndices, multiply, multiply, multiply, multiply, multiply, multiply, multiply, multiply, multiplyInplace, multiplyInplace, multiplyInplace, multiplyInplace, multiplyInplace, multiplyInplace, multiplyInplace, multiplyInplace, permuteDims, prod, reshape, selectDims, slice, squeeze, subtract, subtract, subtract, subtract, subtract, subtract, subtract, subtract, subtractInplace, subtractInplace, subtractInplace, subtractInplace, subtractInplace, subtractInplace, subtractInplace, subtractInplace, sum
-
Methods inherited from interface io.github.hakkelt.ndarrays.NDArray
accumulate, applyOnSlices, contains, contentToString, dataTypeAsString, dtype, equals, forEach, forEachWithCartesianIndices, forEachWithLinearIndices, get, get, getNamePrefix, hashCode, iterator, length, mapOnSlices, ndim, norm, norm, norm, parallelStream, prod, reduceSlices, set, set, shape, shape, spliterator, stream, streamCartesianIndices, streamLinearIndices, sum, toArray, toArray, toArray, toString, writeToFile
-
-
-
-
Method Detail
-
mapOnComplexSlices
public ComplexNDArray<T> mapOnComplexSlices(BiFunction<ComplexNDArray<T>,int[],NDArray<?>> func, int... iterationDims)
Description copied from interface:ComplexNDArrayApply the given function to each slices of the array, and create a new NDArray with the calculated new values. Please note that slices might not be processed in a sequential order!- Specified by:
mapOnComplexSlicesin interfaceComplexNDArray<T extends Number>- Parameters:
func- function that receives slice and its Cartesian coordinate along the iteration dimensions, and returns a new array with the same size as the sliceiterationDims- dimensions along which iteration is performed- Returns:
- the new NDArray with the calculated new values
-
applyOnComplexSlices
public ComplexNDArray<T> applyOnComplexSlices(BiFunction<ComplexNDArray<T>,int[],NDArray<?>> func, int... iterationDims)
Description copied from interface:ComplexNDArrayApply the given function to each slices of the array, and override each entry with the returned slice. Please note that slices might not be processed in a sequential order!- Specified by:
applyOnComplexSlicesin interfaceComplexNDArray<T extends Number>- Parameters:
func- function that receives the value of the current entry and its Cartesian coordinate, and returns a slice from which values are copied to original arrayiterationDims- dimensions along which iteration is performed- Returns:
- itself after the update
-
reduceComplexSlices
public ComplexNDArray<T> reduceComplexSlices(BiFunction<ComplexNDArray<T>,int[],org.apache.commons.math3.complex.Complex> func, int... iterationDims)
Description copied from interface:ComplexNDArrayReduces slices along the specified dimensions in this NDArray to scalar values, reducing the number of dimensions.For example, if
Ais a [5 × 8 × 3] array, thenB = A.reduce(func, 2)returns a [5 × 8] array, andB.get(1,1) == func(A.slice(1, 1, ":"), new int[] { 1, 1 }).- Specified by:
reduceComplexSlicesin interfaceComplexNDArray<T extends Number>- Parameters:
func- reduction function that accepts a slice and its index and returns reduction resultiterationDims- dimensions along which the reduction should be performed- Returns:
- result of reduction of all slices along the specified dimensions
-
real
public NDArray<T> real()
Description copied from interface:ComplexNDArrayReturns a new array holding the real part of the array- Specified by:
realin interfaceComplexNDArray<T extends Number>- Returns:
- the real part of the array
-
imaginary
public NDArray<T> imaginary()
Description copied from interface:ComplexNDArrayReturns a new array holding the imaginary part of the array- Specified by:
imaginaryin interfaceComplexNDArray<T extends Number>- Returns:
- the imaginary part of the array
-
abs
public NDArray<T> abs()
Description copied from interface:ComplexNDArrayReturns a new array holding the magnitude / absolute values of the elements.- Specified by:
absin interfaceComplexNDArray<T extends Number>- Returns:
- a new array holding the magnitude / absolute values of the elements.
-
argument
public NDArray<T> argument()
Description copied from interface:ComplexNDArrayReturns a new array holding the argument / argument of the elements.- Specified by:
argumentin interfaceComplexNDArray<T extends Number>- Returns:
- a new array holding the argument / argument of the elements.
-
similar
public ComplexNDArray<T> similar()
Description copied from interface:NDArrayReturns a new array of the same shape as this NDArray filled with zeros.- Specified by:
similarin interfaceComplexNDArray<T extends Number>- Specified by:
similarin interfaceNDArray<T extends Number>- Overrides:
similarin classAbstractNDArrayView<org.apache.commons.math3.complex.Complex,T extends Number>- Returns:
- a new array of the same shape as this NDArray filled with zeros.
-
copy
public ComplexNDArray<T> copy()
Description copied from interface:NDArrayReturns a copy of this NDArray.
-
apply
public ComplexNDArray<T> apply(UnaryOperator<org.apache.commons.math3.complex.Complex> func)
Description copied from interface:NDArrayApply the given function to each element of the array, and override each entry with the calculated new values. Please note that entries might not be processed in a sequential order!- Specified by:
applyin interfaceComplexNDArray<T extends Number>- Specified by:
applyin interfaceNDArray<T extends Number>- Overrides:
applyin classAbstractNDArray<org.apache.commons.math3.complex.Complex,T extends Number>- Parameters:
func- function that receives the value of the current entry, and returns the new value- Returns:
- itself after the update
-
applyWithLinearIndices
public ComplexNDArray<T> applyWithLinearIndices(BiFunction<org.apache.commons.math3.complex.Complex,Integer,org.apache.commons.math3.complex.Complex> func)
Description copied from interface:NDArrayApply the given function to each element of the array, and override each entry with the calculated new values. Please note that entries might not be processed in a sequential order!- Specified by:
applyWithLinearIndicesin interfaceComplexNDArray<T extends Number>- Specified by:
applyWithLinearIndicesin interfaceNDArray<T extends Number>- Overrides:
applyWithLinearIndicesin classAbstractNDArray<org.apache.commons.math3.complex.Complex,T extends Number>- Parameters:
func- function that receives the value of the current entry and its linear index, and returns the new value- Returns:
- itself after the update
-
applyWithCartesianIndices
public ComplexNDArray<T> applyWithCartesianIndices(BiFunction<org.apache.commons.math3.complex.Complex,int[],org.apache.commons.math3.complex.Complex> func)
Description copied from interface:NDArrayApply the given function to each element of the array, and override each entry with the calculated new values. Please note that entries might not be processed in a sequential order!- Specified by:
applyWithCartesianIndicesin interfaceComplexNDArray<T extends Number>- Specified by:
applyWithCartesianIndicesin interfaceNDArray<T extends Number>- Overrides:
applyWithCartesianIndicesin classAbstractNDArray<org.apache.commons.math3.complex.Complex,T extends Number>- Parameters:
func- function that receives the value of the current entry and its Cartesian coordinate, and returns the new value- Returns:
- itself after the update
-
fillUsingLinearIndices
public ComplexNDArray<T> fillUsingLinearIndices(IntFunction<org.apache.commons.math3.complex.Complex> func)
Description copied from interface:NDArrayApply the given function to each element of the array, and override each entry with the calculated new values. Please note that entries might not be processed in a sequential order!- Specified by:
fillUsingLinearIndicesin interfaceComplexNDArray<T extends Number>- Specified by:
fillUsingLinearIndicesin interfaceNDArray<T extends Number>- Overrides:
fillUsingLinearIndicesin classAbstractNDArray<org.apache.commons.math3.complex.Complex,T extends Number>- Parameters:
func- function that receives the linear index of the current entry, and returns the new value- Returns:
- itself after the update
-
fillUsingCartesianIndices
public ComplexNDArray<T> fillUsingCartesianIndices(Function<int[],org.apache.commons.math3.complex.Complex> func)
Description copied from interface:NDArrayApply the given function to each element of the array, and override each entry with the calculated new values. Please note that entries might not be processed in a sequential order!- Specified by:
fillUsingCartesianIndicesin interfaceComplexNDArray<T extends Number>- Specified by:
fillUsingCartesianIndicesin interfaceNDArray<T extends Number>- Overrides:
fillUsingCartesianIndicesin classAbstractNDArray<org.apache.commons.math3.complex.Complex,T extends Number>- Parameters:
func- function that receives the Cartesian coordinate of the current entry, and returns the new value- Returns:
- itself after the update
-
set
public void set(Number value, int linearIndex)
Description copied from interface:NDArraySets the value of an element specified by linear indexing.Linear indexing: It selects the ith element using the column-major iteration order that linearly spans the entire array. in its particular dimension.
Negative indexing is supported, e.g. -1 refers to the last element, -2 refers to the item before the last one, etc.
-
set
public void set(Number value, int... indices)
Description copied from interface:NDArraySets the value of an element specified by cartesian indexing.Cartesian indexing: The ordinary way to index into an N-dimensional array is to use exactly N indices; each index selects the position(s) in its particular dimension.
Negative indexing is supported, e.g. assuming a 3×4 NDArray, index [2,-1] equals to [2,3], and [-1,-3] is an equivalent of [2,1].
-
setReal
public void setReal(Number value, int linearIndex)
Description copied from interface:ComplexNDArraySets the real part of an element specified by linear indexing.Linear indexing: It selects the ith element using the column-major iteration order that linearly spans the entire array.
Negative indexing is supported: e.g. -1 refers to the last element, -2 refers to the item before the last one, etc.
Note: If used on complex arrays, the imaginary part of the assigned element will be untouched.
- Specified by:
setRealin interfaceComplexNDArray<T extends Number>- Overrides:
setRealin classAbstractNDArray<org.apache.commons.math3.complex.Complex,T extends Number>- Parameters:
value- real value to be assigned as real part of some elementlinearIndex- linear index
-
setImag
public void setImag(Number value, int linearIndex)
Description copied from interface:ComplexNDArraySets the imaginary part of an element specified by linear indexing.Linear indexing: It selects the ith element using the column-major iteration order that linearly spans the entire array.
Negative indexing is supported: e.g. -1 refers to the last element, -2 refers to the item before the last one, etc.
Note: If used on complex arrays, the imaginary part of the assigned element will be untouched.
- Specified by:
setImagin interfaceComplexNDArray<T extends Number>- Overrides:
setImagin classAbstractNDArray<org.apache.commons.math3.complex.Complex,T extends Number>- Parameters:
value- imaginary value to be assigned as imaginary part of some elementlinearIndex- linear index
-
setReal
public void setReal(Number value, int... indices)
Description copied from interface:ComplexNDArraySets the real part of an element specified by cartesian indexing.Cartesian indexing: The ordinary way to index into an N-dimensional array is to use exactly N indices; each index selects the position(s) in its particular dimension.
Negative indexing is supported: e.g. assuming a 3×4 NDArray, index [2,-1] equals to [2,3], and [-1,-3] is an equivalent of [2,1].
Note: If used on complex arrays, the imaginary part of the assigned element will be untouched.
- Specified by:
setRealin interfaceComplexNDArray<T extends Number>- Overrides:
setRealin classAbstractNDArray<org.apache.commons.math3.complex.Complex,T extends Number>- Parameters:
value- real value to be assigned as real part of some elementindices- cartesian coordinates
-
setImag
public void setImag(Number value, int... indices)
Description copied from interface:ComplexNDArraySets the imaginary part of an element specified by cartesian indexing.Cartesian indexing: The ordinary way to index into an N-dimensional array is to use exactly N indices; each index selects the position(s) in its particular dimension.
Negative indexing is supported: e.g. assuming a 3×4 NDArray, index [2,-1] equals to [2,3], and [-1,-3] is an equivalent of [2,1].
Note: If used on complex arrays, the imaginary part of the assigned element will be untouched.
- Specified by:
setImagin interfaceComplexNDArray<T extends Number>- Overrides:
setImagin classAbstractNDArray<org.apache.commons.math3.complex.Complex,T extends Number>- Parameters:
value- imaginary value to be assigned as imaginary part of some elementindices- cartesian coordinates
-
-