Gets the T type value at the dimension address provided.
Since this object can have n dimensions, value's position in the Matrix is
referred to as it's dimensionAddress
. If the length of the dimensionAddress
does not match the matrix's dimensions an error is thrown. If at each point in
the dimension address, the value is out of bounds of that dimensions range, an
error is thrown. Returns The value at the given dimensional address.
Source
T getAt(List<int> dimensionAddress) {
List get = this._core;
T returnVal = null;
if (this._matrixDimension == dimensionAddress.length) {
for (int k = 0; k < dimensionAddress.length; k++) {
if (dimensionAddress[k] < get.length) {
if ((k + 1) == dimensionAddress.length) {
returnVal = get[dimensionAddress[k]];
} else {
get = get[dimensionAddress[k]];
}
} else {
///Calcuate how far out of bounds in Dimension k the value is.
int outOfBounds = dimensionAddress[k] - get.length;
throw new DimensionalMisMatchException(
"ERROR: Dimension MisMatch at Dimension $k of the NMatrix. Out of Bounds by: $outOfBounds.");
}
}
} else {
///Gets the difference in D
int dimDiff = dimensionAddress.length - this._matrixDimension;
throw new DimensionalMisMatchException(
"ERROR: Dimension MisMatch. NMatrix object does not have same number dimensions as the dimensionsAddress provided. Dimension Dif: $dimDiff.");
}
return returnVal;
}