public static GenTensor <T, TWrapper> TensorDeterminantGaussianSimple(GenTensor <T, TWrapper> t) { #if ALLOW_EXCEPTIONS InvalidShapeException.NeedTensorSquareMatrix(t); #endif var res = GenTensor <T, TWrapper> .CreateTensor(t.Shape.SubShape(0, 2), ind => t.GetSubtensor(ind).DeterminantGaussianSimple()); return(res); }
public static void TensorMatrixInvert(GenTensor <T, TWrapper> t) { #if ALLOW_EXCEPTIONS InvalidShapeException.NeedTensorSquareMatrix(t); #endif foreach (var ind in t.IterateOverMatrices()) { t.GetSubtensor(ind).InvertMatrix(); } }
public static GenTensor <T, TWrapper> TensorMatrixPower(GenTensor <T, TWrapper> m, int power, Threading threading) { #if ALLOW_EXCEPTIONS InvalidShapeException.NeedTensorSquareMatrix(m); #endif var res = new GenTensor <T, TWrapper>(m.Shape); foreach (var ind in res.IterateOverMatrices()) { res.SetSubtensor( MatrixPower(m.GetSubtensor(ind), power, threading), ind ); } return(res); }
public static GenTensor <T, TWrapper> TensorMatrixDivide(GenTensor <T, TWrapper> a, GenTensor <T, TWrapper> b) { #if ALLOW_EXCEPTIONS InvalidShapeException.NeedTensorSquareMatrix(a); InvalidShapeException.NeedTensorSquareMatrix(b); if (a.Shape != b.Shape) { throw new InvalidShapeException("Should be of the same shape"); } #endif var res = new GenTensor <T, TWrapper>(a.Shape); foreach (var ind in res.IterateOverMatrices()) { res.SetSubtensor( MatrixDivide( a.GetSubtensor(ind), b.GetSubtensor(ind) ), ind); } return(res); }
public InvalidSpatialShapeException(InvalidShapeException invalidShapeException, string invalidDocumentId) : base(invalidShapeException.Message, invalidShapeException) { this.invalidDocumentId = invalidDocumentId; }