public unsafe static MatrixCF operator /(MatrixCF mat1, MatrixCF mat2) { var result = new MatrixCF(mat1.NumRows, mat1.NumCols); ComplexF *pResult = result.Data; ComplexF *pMat1 = mat1.Data; ComplexF *pMat2 = mat2.Data; for (int i = 0; i < result.TotalSize; i++) { pResult[i] = pMat1[i] / pMat2[i]; } return(result); }
/// <summary> /// Computes the product of the current matrix and another matrix. /// </summary> /// <param name="mat">A matrix by which to multiply the current matrix.</param> /// <returns>A matrix that is the product of the input matrix and the other matrix.</returns> public unsafe MatrixCF Dot(MatrixCF mat) { var result = new MatrixCF(this.NumRows, mat.NumCols); ComplexF *pResult = result.Data; ComplexF *pThis = this.Data; ComplexF *pMat = mat.Data; for (int y = 0; y < this.NumRows; y++) { int i = y * this.NumCols; for (int x = 0; x < mat.NumCols; x++) { int j = x; var sum = new ComplexF(); for (int z = 0; z < this.NumCols; z++, j += mat.NumCols) { sum += pThis[i + z] * pMat[j]; } pResult[y * mat.NumCols + x] = sum; } } return(result); }