Exemple #1
0
 /// <summary>
 /// A / B
 /// Finds such C = A / B that A = C * B
 ///
 /// O(N^5)
 /// </summary>
 public static GenTensor <T> MatrixDivide(GenTensor <T> a, GenTensor <T> b)
 {
     #if ALLOW_EXCEPTIONS
     if (!a.IsSquareMatrix || !b.IsSquareMatrix)
     {
         throw new InvalidShapeException("Both should be square matrices");
     }
     if (a.Shape != b.Shape)
     {
         throw new InvalidShapeException("Given matrices should be of the same shape");
     }
     #endif
     var fwd = b.Forward();
     fwd.InvertMatrix();
     return(MatrixMultiply(a, fwd));
 }