Package mklab.JGNN.core.matrix
Class AccessCol
java.lang.Object
mklab.JGNN.core.Tensor
mklab.JGNN.core.matrix.AccessCol
Accesses a column of a
Matrix as if it were a dense Tensor.
Prefer using Matrix.accessCol(long), which wraps
usage of this class. Instances of this class share elements with the matrix
which they access and do not allocate new memory.- Author:
- Emmanouil Krasanakis
- See Also:
-
Field Summary
Fields inherited from class mklab.JGNN.core.Tensor
vectorization -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidallocate(long size) longProvides an estimation for the non-zero number of elements stored in the tensor, where this number is equal to the size for dense tensors, but equal to the actual number of non-zero elements for sparse tensors.doubleget(long pos) Retrieves the value of a tensor element at a given position.voidpersist()If supported by the subclassed tensor, invalidates calls toTensor.release()so that memory is de-allocated only when object references expire.put(long pos, double value) Assign a value to a tensor element.voidrelease()If the subclassed tensor allows it, release all memory it takes up so that the garbage collector will eventually clean it up.Retrieves positions within the tensor that may hold non-zero elements.zeroCopy(long size) Creates a tensor of the same class with a given size and all element set to zero.Methods inherited from class mklab.JGNN.core.Tensor
abs, accessSubtensor, accessSubtensor, add, add, argmax, argmin, asColumn, asRow, assertFinite, assertMatching, assertSize, assign, cast, copy, density, describe, determineZeroCopy, dot, dot, expMinusOne, fromDouble, fromRange, fromRange, getDimensionName, getNonZeroElements, init, inverse, isMatching, iterator, log, max, min, multiply, multiply, negative, norm, normalized, putAdd, selfAbs, selfAdd, selfAdd, selfAdd, selfExpMinusOne, selfInverse, selfLog, selfMultiply, selfMultiply, selfNegative, selfSqrt, selfSubtract, setDimensionName, setDimensionName, setToNormalized, setToOnes, setToProbability, setToRandom, setToRandom, setToUniform, setToZero, size, sqrt, subtract, sum, toArray, toDouble, toProbability, toString, zeroCopy, zeroCopyMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
AccessCol
Instantiates a see-through access of a matrix column.- Parameters:
matrix- The base matrix.col- Which column to access.
-
-
Method Details
-
estimateNumNonZeroElements
public long estimateNumNonZeroElements()Description copied from class:TensorProvides an estimation for the non-zero number of elements stored in the tensor, where this number is equal to the size for dense tensors, but equal to the actual number of non-zero elements for sparse tensors. Basically, this quantity is proportional to the allocated memory.- Overrides:
estimateNumNonZeroElementsin classTensor- Returns:
- A long number equal to or less to the tensor size.
- See Also:
-
allocate
protected void allocate(long size) -
put
Description copied from class:TensorAssign a value to a tensor element. All tensor operations use this function to wrap element assignments. -
get
public double get(long pos) Description copied from class:TensorRetrieves the value of a tensor element at a given position. All tensor operations use this function to wrap element retrieval. -
zeroCopy
Description copied from class:TensorCreates a tensor of the same class with a given size and all element set to zero. -
traverseNonZeroElements
Description copied from class:TensorRetrieves positions within the tensor that may hold non-zero elements. This guarantees that all non-zero elements positions are traversed but some of the returned positions could hold zero elements. For example,DenseTensortraverses all of its elements this way, whereasSparseTensorindeed traverses only non-zero elements.- Specified by:
traverseNonZeroElementsin classTensor- Returns:
- An iterator that traverses positions within the tensor.
-
release
public void release()Description copied from class:TensorIf the subclassed tensor allows it, release all memory it takes up so that the garbage collector will eventually clean it up. This memory will be released anyway by Java once there are no more references to the object. -
persist
public void persist()Description copied from class:TensorIf supported by the subclassed tensor, invalidates calls toTensor.release()so that memory is de-allocated only when object references expire.
-