Package io.github.hakkelt.ndarrays.basic
Class BasicDoubleNDArray
- java.lang.Object
-
- io.github.hakkelt.ndarrays.internal.AbstractNDArray<T,T>
-
- io.github.hakkelt.ndarrays.internal.AbstractRealNDArray<Double>
-
- io.github.hakkelt.ndarrays.AbstractDoubleNDArray
-
- io.github.hakkelt.ndarrays.basic.BasicDoubleNDArray
-
public class BasicDoubleNDArray extends AbstractDoubleNDArray
Reference implementation for the NDArray of double (double precision, 64 bit floating-point) values.
-
-
Constructor Summary
Constructors Constructor Description BasicDoubleNDArray(int... shape)
Simple constructor that defines only the shape of the NDArray and fills it with zeros.BasicDoubleNDArray(NDArray<? extends Number> array)
Copy constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description NDArray<Double>
copyFrom(NDArray<?> array)
Updates this NDArray with the elements of the NDArray given as parameter.boolean
equals(Object other)
Compares the specified object with this NDArray for equality.static Collector<Object,List<Object>,NDArray<Double>>
getCollector(int... shape)
String
getNamePrefix()
Returns a string that identifies the implementation behind this current object.int
hashCode()
This method is unsupported because NDArrays should not be used as keys in hash-based collections.static NDArray<Double>
of(byte... array)
Factory method that creates an NDArray from a list or 1D array of double values.static NDArray<Double>
of(double... array)
Factory method that creates an NDArray from a list or 1D array of double values.static NDArray<Double>
of(float... array)
Factory method that creates an NDArray from a list or 1D array of double values.static NDArray<Double>
of(int... array)
Factory method that creates an NDArray from a list or 1D array of double values.static NDArray<Double>
of(long... array)
Factory method that creates an NDArray from a list or 1D array of double values.static NDArray<Double>
of(short... array)
Factory method that creates an NDArray from a list or 1D array of double values.static NDArray<Double>
of(Object[] array)
Factory method that creates an NDArray from a multi-dimensional array of numeric values.static BasicDoubleNDArray
readFromFile(File file)
Load the content of the given file into a new BasicDoubleNDArray.-
Methods inherited from class io.github.hakkelt.ndarrays.AbstractDoubleNDArray
dtype, set, set
-
Methods inherited from class io.github.hakkelt.ndarrays.internal.AbstractRealNDArray
dataTypeAsString
-
Methods inherited from class io.github.hakkelt.ndarrays.internal.AbstractNDArray
accumulate, apply, applyOnSlices, applyWithCartesianIndices, applyWithLinearIndices, contains, contentToString, contentToString, copy, fillUsingCartesianIndices, fillUsingLinearIndices, forEach, forEachWithCartesianIndices, forEachWithLinearIndices, get, get, getImag, getImag, getReal, getReal, iterator, length, mapOnSlices, maybeParallelStream, ndim, norm, norm, parallelStream, prod, reduceSlices, set, set, setImag, setImag, setReal, setReal, shape, shape, similar, spliterator, stream, streamCartesianIndices, streamLinearIndices, sum, toArray, toArray, toArray, toString, writeToFile
-
Methods inherited from interface io.github.hakkelt.ndarrays.NDArray
accumulate, add, add, add, add, add, add, add, addInplace, addInplace, addInplace, addInplace, addInplace, addInplace, addInplace, apply, applyOnSlices, applyWithCartesianIndices, applyWithLinearIndices, contains, contentToString, contentToString, copy, divide, divide, divide, divide, divide, divide, divide, divideInplace, divideInplace, divideInplace, divideInplace, divideInplace, divideInplace, divideInplace, fillUsingCartesianIndices, fillUsingLinearIndices, forEach, forEachWithCartesianIndices, forEachWithLinearIndices, get, get, iterator, length, mapOnSlices, multiply, multiply, multiply, multiply, multiply, multiply, multiply, multiplyInplace, multiplyInplace, multiplyInplace, multiplyInplace, multiplyInplace, multiplyInplace, multiplyInplace, ndim, norm, norm, norm, parallelStream, prod, reduceSlices, set, set, shape, shape, similar, spliterator, stream, streamCartesianIndices, streamLinearIndices, subtract, subtract, subtract, subtract, subtract, subtract, subtract, subtractInplace, subtractInplace, subtractInplace, subtractInplace, subtractInplace, subtractInplace, subtractInplace, sum, toArray, toArray, toArray, toString, writeToFile
-
Methods inherited from interface io.github.hakkelt.ndarrays.internal.RealNDArray
accumulate, add, addInplace, concatenate, copyFrom, copyFrom, copyFrom, copyFrom, copyFrom, copyFrom, copyFrom, divide, divideInplace, dropDims, fill, fill, inverseMask, map, mapWithCartesianIndices, mapWithLinearIndices, mask, mask, maskWithCartesianIndices, maskWithLinearIndices, multiply, multiplyInplace, permuteDims, prod, reshape, selectDims, slice, squeeze, subtract, subtractInplace, sum
-
-
-
-
Method Detail
-
of
public static NDArray<Double> of(float... array)
Factory method that creates an NDArray from a list or 1D array of double values.- Parameters:
array
- a list or 1D array of double values from which a BasicDoubleNDArray is created.- Returns:
- an NDArray created from a list or 1D array of double values
-
of
public static NDArray<Double> of(double... array)
Factory method that creates an NDArray from a list or 1D array of double values.- Parameters:
array
- a list or 1D array of double values from which a BasicDoubleNDArray is created.- Returns:
- an NDArray created from a list or 1D array of double values
-
of
public static NDArray<Double> of(byte... array)
Factory method that creates an NDArray from a list or 1D array of double values.- Parameters:
array
- a list or 1D array of double values from which a BasicDoubleNDArray is created.- Returns:
- an NDArray created from a list or 1D array of double values
-
of
public static NDArray<Double> of(short... array)
Factory method that creates an NDArray from a list or 1D array of double values.- Parameters:
array
- a list or 1D array of double values from which a BasicDoubleNDArray is created.- Returns:
- an NDArray created from a list or 1D array of double values
-
of
public static NDArray<Double> of(int... array)
Factory method that creates an NDArray from a list or 1D array of double values.- Parameters:
array
- a list or 1D array of double values from which a BasicDoubleNDArray is created.- Returns:
- an NDArray created from a list or 1D array of double values
-
of
public static NDArray<Double> of(long... array)
Factory method that creates an NDArray from a list or 1D array of double values.- Parameters:
array
- a list or 1D array of double values from which a BasicDoubleNDArray is created.- Returns:
- an NDArray created from a list or 1D array of double values
-
readFromFile
public static BasicDoubleNDArray readFromFile(File file) throws IOException
Load the content of the given file into a new BasicDoubleNDArray.Only the files written by function writeToFile can be loaded by this function.
- Example:
NDArray<Float> array = new BasicFloatNDArray(128, 128).fill(5); array.writeToFile(new File("array.nda")); NDArray<Double> array2 = BasicDoubleNDArray.readFromFile(new File("array.nda")); assertEquals(array, array2);
- Parameters:
file
- file from which the content of the NDArray is read (the extension of the file can be arbitrary, but .nda is recommended)- Returns:
- a new BasicDoubleNDArray whose shape and content is loaded from the given file
- Throws:
IOException
- when the given file cannot be opened for read
-
of
public static NDArray<Double> of(Object[] array)
Factory method that creates an NDArray from a multi-dimensional array of numeric values.- Parameters:
array
- a multi-dimensional array of numeric values from which a BasicDoubleNDArray is created.- Returns:
- an NDArray created from a multi-dimensional array of numeric values
-
copyFrom
public NDArray<Double> copyFrom(NDArray<?> array)
Description copied from interface:NDArray
Updates this NDArray with the elements of the NDArray given as parameter.Note: the parameter NDArray must have the same shape and this NDArray!
-
getNamePrefix
public String getNamePrefix()
Description copied from interface:NDArray
Returns a string that identifies the implementation behind this current object. The output of the toString() function starts with this string.- Returns:
- a string that identifies the implementation
-
getCollector
public static Collector<Object,List<Object>,NDArray<Double>> getCollector(int... shape)
-
equals
public boolean equals(Object other)
Description copied from interface:NDArray
Compares the specified object with this NDArray for equality. Two arrays are equal, if they are both real or both complex, and they are element-wise equal. If the specified object is not NDArray then the function returns false.
-
hashCode
@Generated public int hashCode()
Description copied from interface:NDArray
This method is unsupported because NDArrays should not be used as keys in hash-based collections.
-
-