public static double Nrm2(MatrixExpression a) { var i = a.Evaluate(); var r = Blas.nrm2(i.Length, i.Array, 0, 1); if (a is not MatrixInput) { i.Dispose(); } return(r); }
public static (matrix, matrix) Modf(MatrixExpression a) { var tru = a.Evaluate(); if (a is MatrixInput) { tru = Copy(tru); } var rem = new matrix(tru.Rows, tru.Cols); Vml.Modf(tru.Length, tru.Array, tru.Array, rem.Array); return(tru, rem); }
public static (matrix, matrix) SinCos(MatrixExpression a) { var sin = a.Evaluate(); if (a is MatrixInput) { sin = Copy(sin); } var cos = new matrix(sin.Rows, sin.Cols); Vml.SinCos(sin.Length, sin.Array, sin.Array, cos.Array); return(sin, cos); }
public static (int, int) Iamin(MatrixExpression a) { var i = a.Evaluate(); int r = Blas.iamin(i.Length, i.Array, 0, 1); if (a is not MatrixInput) { i.Dispose(); } int col = Math.DivRem(r, i.Rows, out int row); return(row, col); }
public static (matrix, vector) Eigens(MatrixExpression a) { var v = a.Evaluate(); if (v.Rows != v.Cols) { ThrowHelper.ThrowIncorrectDimensionsForOperation(); } if (a is MatrixInput) { v = Copy(v); } var w = new vector(v.Rows); ThrowHelper.Check(Lapack.syev(Layout.ColMajor, 'V', UpLoChar.Lower, v.Rows, v.Array, v.Rows, w.Array)); return(v, w); }
public static double Det(MatrixExpression a) { var m = a.Evaluate(); if (a is MatrixInput) { m = Copy(m); } var ipiv = Pool.Int.Rent(m.Rows); ThrowHelper.Check(Lapack.getrf(Layout.ColMajor, m.Rows, m.Rows, m.Array, m.Rows, ipiv)); Pool.Int.Return(ipiv); double r = m[0, 0]; for (int i = 1; i < m.Rows; i++) { r *= m[i, i]; } m.Dispose(); return(-r); }