From 71ccf00c9bd5e984c2c9ca6be476150a1b85250b Mon Sep 17 00:00:00 2001 From: Marcus Cuda Date: Sat, 6 Nov 2010 20:26:10 +0800 Subject: [PATCH] native: native providers now extend mananaged provider split native providers it type based templates --- .../Atlas/AtlasLinearAlgebraProvider.cs | 2592 ----------------- .../Atlas/AtlasLinearAlgebraProvider.tt | 4 - .../LinearAlgebra/Atlas/SafeNativeMethods.cs | 121 - .../LinearAlgebra/Atlas/SafeNativeMethods.tt | 9 - .../ManagedLinearAlgebraProvider.Complex.cs | 66 +- .../ManagedLinearAlgebraProvider.Complex32.cs | 66 +- .../ManagedLinearAlgebraProvider.Double.cs | 66 +- .../ManagedLinearAlgebraProvider.Single.cs | 66 +- .../Mkl/MklLinearAlgebraProvider.Complex.tt | 10 + .../Mkl/MklLinearAlgebraProvider.Complex32.tt | 10 + .../Mkl/MklLinearAlgebraProvider.cs | 2591 ---------------- .../Mkl/MklLinearAlgebraProvider.double.tt | 10 + .../Mkl/MklLinearAlgebraProvider.float.tt | 10 + .../Mkl/MklLinearAlgebraProvider.tt | 4 - .../LinearAlgebra/Mkl/SafeNativeMethods.cs | 160 - .../NativeAlgebraProvider.include | 2080 +------------ src/Numerics/Numerics.csproj | 45 + 17 files changed, 278 insertions(+), 7632 deletions(-) delete mode 100644 src/Numerics/Algorithms/LinearAlgebra/Atlas/AtlasLinearAlgebraProvider.cs delete mode 100644 src/Numerics/Algorithms/LinearAlgebra/Atlas/AtlasLinearAlgebraProvider.tt delete mode 100644 src/Numerics/Algorithms/LinearAlgebra/Atlas/SafeNativeMethods.cs delete mode 100644 src/Numerics/Algorithms/LinearAlgebra/Atlas/SafeNativeMethods.tt create mode 100644 src/Numerics/Algorithms/LinearAlgebra/Mkl/MklLinearAlgebraProvider.Complex.tt create mode 100644 src/Numerics/Algorithms/LinearAlgebra/Mkl/MklLinearAlgebraProvider.Complex32.tt delete mode 100644 src/Numerics/Algorithms/LinearAlgebra/Mkl/MklLinearAlgebraProvider.cs create mode 100644 src/Numerics/Algorithms/LinearAlgebra/Mkl/MklLinearAlgebraProvider.double.tt create mode 100644 src/Numerics/Algorithms/LinearAlgebra/Mkl/MklLinearAlgebraProvider.float.tt delete mode 100644 src/Numerics/Algorithms/LinearAlgebra/Mkl/MklLinearAlgebraProvider.tt delete mode 100644 src/Numerics/Algorithms/LinearAlgebra/Mkl/SafeNativeMethods.cs diff --git a/src/Numerics/Algorithms/LinearAlgebra/Atlas/AtlasLinearAlgebraProvider.cs b/src/Numerics/Algorithms/LinearAlgebra/Atlas/AtlasLinearAlgebraProvider.cs deleted file mode 100644 index dd3e9a4e..00000000 --- a/src/Numerics/Algorithms/LinearAlgebra/Atlas/AtlasLinearAlgebraProvider.cs +++ /dev/null @@ -1,2592 +0,0 @@ -// -// Math.NET Numerics, part of the Math.NET Project -// http://mathnet.opensourcedotnet.info -// -// Copyright (c) 2009 Math.NET -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. -// - -/* This file is automatically generated - do not modify it. - Change NativeLinearAlgebraProvider.include instead. - Last generated on UTC 2010-07-06 18:34:45Z -*/ - -namespace MathNet.Numerics.Algorithms.LinearAlgebra.Atlas -{ - using System; - using System.Numerics; - using Properties; - - /// - /// The managed linear algebra provider. - /// - public class AtlasLinearAlgebraProvider : ILinearAlgebraProvider - { - private readonly ILinearAlgebraProvider _managedProvider = new ManagedLinearAlgebraProvider(); - - #region ILinearAlgebraProvider Members - - /// - /// Adds a scaled vector to another: y += alpha*x. - /// - /// The vector to update. - /// The value to scale by. - /// The vector to add to . - /// This equivalent to the AXPY BLAS routine. - public void AddVectorToScaledVector(double[] y, double alpha, double[] x) - { - if (y == null) - { - throw new ArgumentNullException("y"); - } - - if (x == null) - { - throw new ArgumentNullException("x"); - } - - if (y.Length != x.Length) - { - throw new ArgumentException(Resources.ArgumentVectorsSameLength); - } - - if (alpha == 0.0) - { - return; - } - - SafeNativeMethods.d_axpy(y.Length, alpha, x, y); - } - - /// - /// Scales an array. Can be used to scale a vector and a matrix. - /// - /// The scalar. - /// The values to scale. - /// This is equivalent to the SCAL BLAS routine. - public void ScaleArray(double alpha, double[] x) - { - if (x == null) - { - throw new ArgumentNullException("x"); - } - - if (alpha == 1.0) - { - return; - } - - SafeNativeMethods.d_scale(x.Length, alpha, x); - } - - /// - /// Computes the dot product of x and y. - /// - /// The vector x. - /// The vector y. - /// The dot product of x and y. - /// This is equivalent to the DOT BLAS routine. - public double DotProduct(double[] x, double[] y) - { - if (y == null) - { - throw new ArgumentNullException("y"); - } - - if (x == null) - { - throw new ArgumentNullException("x"); - } - - if (x.Length != y.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - - return SafeNativeMethods.d_dot_product(x.Length, x, y); - } - - /// - /// Does a point wise add of two arrays z = x + y. This can be used - /// to add vectors or matrices. - /// - /// The array x. - /// The array y. - /// The result of the addition. - /// There is no equivalent BLAS routine, but many libraries - /// provide optimized (parallel and/or vectorized) versions of this - /// routine. - public void AddArrays(double[] x, double[] y, double[] result) - { - if (y == null) - { - throw new ArgumentNullException("y"); - } - - if (x == null) - { - throw new ArgumentNullException("x"); - } - - if (x.Length != y.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - - if (x.Length != result.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - - _managedProvider.AddArrays(x, y, result); - } - - /// - /// Does a point wise subtraction of two arrays z = x - y. This can be used - /// to subtract vectors or matrices. - /// - /// The array x. - /// The array y. - /// The result of the subtraction. - /// There is no equivalent BLAS routine, but many libraries - /// provide optimized (parallel and/or vectorized) versions of this - /// routine. - public void SubtractArrays(double[] x, double[] y, double[] result) - { - if (y == null) - { - throw new ArgumentNullException("y"); - } - - if (x == null) - { - throw new ArgumentNullException("x"); - } - - if (x.Length != y.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - - if (x.Length != result.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - - _managedProvider.SubtractArrays(x, y, result); - } - - /// - /// Does a point wise multiplication of two arrays z = x * y. This can be used - /// to multiple elements of vectors or matrices. - /// - /// The array x. - /// The array y. - /// The result of the point wise multiplication. - /// There is no equivalent BLAS routine, but many libraries - /// provide optimized (parallel and/or vectorized) versions of this - /// routine. - public void PointWiseMultiplyArrays(double[] x, double[] y, double[] result) - { - if (y == null) - { - throw new ArgumentNullException("y"); - } - - if (x == null) - { - throw new ArgumentNullException("x"); - } - - if (x.Length != y.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - - if (x.Length != result.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - - _managedProvider.PointWiseMultiplyArrays(x, y, result); - } - - /// - /// Computes the requested of the matrix. - /// - /// The type of norm to compute. - /// The number of rows in the matrix. - /// The number of columns in the matrix. - /// The matrix to compute the norm from. - /// - /// The requested of the matrix. - /// - public double MatrixNorm(Norm norm, int rows, int columns, double[] matrix) - { - throw new NotImplementedException(); - } - - /// - /// Computes the requested of the matrix. - /// - /// The type of norm to compute. - /// The number of rows in the matrix. - /// The number of columns in the matrix. - /// The matrix to compute the norm from. - /// The work array. Only used when - /// and needs to be have a length of at least M (number of rows of . - /// - /// The requested of the matrix. - /// - public double MatrixNorm(Norm norm, int rows, int columns, double[] matrix, double[] work) - { - throw new NotImplementedException(); - } - - /// - /// Multiples two matrices. result = x * y - /// - /// The x matrix. - /// The number of rows in the x matrix. - /// The number of columns in the x matrix. - /// The y matrix. - /// The number of rows in the y matrix. - /// The number of columns in the y matrix. - /// Where to store the result of the multiplication. - /// This is a simplified version of the BLAS GEMM routine with alpha - /// set to 1.0 and beta set to 0.0, and x and y are not transposed. - public void MatrixMultiply(double[] x, int rowsX, int columnsX, double[] y, int rowsY, int columnsY, double[] result) - { - MatrixMultiplyWithUpdate(Transpose.DontTranspose, Transpose.DontTranspose, 1.0, x, rowsX, columnsX, y, rowsY, columnsY, 0.0, result); - } - - /// - /// Multiplies two matrices and updates another with the result. c = alpha*op(a)*op(b) + beta*c - /// - /// How to transpose the matrix. - /// How to transpose the matrix. - /// The value to scale matrix. - /// The a matrix. - /// The number of rows in the matrix. - /// The number of columns in the matrix. - /// The b matrix - /// The number of rows in the matrix. - /// The number of columns in the matrix. - /// The value to scale the matrix. - /// The c matrix. - public void MatrixMultiplyWithUpdate(Transpose transposeA, Transpose transposeB, double alpha, double[] a, - int rowsA, int columnsA, double[] b, int rowsB, int columnsB, double beta, double[] c) - { - if (a == null) - { - throw new ArgumentNullException("a"); - } - - if (b == null) - { - throw new ArgumentNullException("b"); - } - - if (c == null) - { - throw new ArgumentNullException("c"); - } - - var m = transposeA == Transpose.DontTranspose ? rowsA : columnsA; - var n = transposeB == Transpose.DontTranspose ? columnsB : rowsB; - var k = transposeA == Transpose.DontTranspose ? columnsA : rowsA; - - if( c.Length != rowsA * columnsB) - { - throw new ArgumentException(Resources.ArgumentMatrixDimensions); - } - - if (columnsA != rowsB) - { - throw new ArgumentException(Resources.ArgumentMatrixDimensions); - } - - SafeNativeMethods.d_matrix_multiply(transposeA, transposeB, m, n, k, alpha, a, b, beta, c); - } - - /// - /// Computes the LUP factorization of A. P*A = L*U. - /// - /// An by matrix. The matrix is overwritten with the - /// the LU factorization on exit. The lower triangular factor L is stored in under the diagonal of (the diagonal is always 1.0 - /// for the L factor). The upper triangular factor U is stored on and above the diagonal of . - /// The order of the square matrix . - /// On exit, it contains the pivot indices. The size of the array must be . - /// This is equivalent to the GETRF LAPACK routine. - public void LUFactor(double[] data, int order, int[] ipiv) - { - throw new NotImplementedException(); - } - - /// - /// Computes the inverse of matrix using LU factorization. - /// - /// The N by N matrix to invert. Contains the inverse On exit. - /// The order of the square matrix . - /// This is equivalent to the GETRF and GETRI LAPACK routines. - public void LUInverse(double[] a, int order) - { - throw new NotImplementedException(); - } - - /// - /// Computes the inverse of a previously factored matrix. - /// - /// The LU factored N by N matrix. Contains the inverse On exit. - /// The order of the square matrix . - /// The pivot indices of . - /// This is equivalent to the GETRI LAPACK routine. - public void LUInverseFactored(double[] a, int order, int[] ipiv) - { - throw new NotImplementedException(); - } - - /// - /// Computes the inverse of matrix using LU factorization. - /// - /// The N by N matrix to invert. Contains the inverse On exit. - /// The order of the square matrix . - /// The work array. The array must have a length of at least N, - /// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal - /// work size value. - /// This is equivalent to the GETRF and GETRI LAPACK routines. - public void LUInverse(double[] a, int order, double[] work) - { - throw new NotImplementedException(); - } - - /// - /// Computes the inverse of a previously factored matrix. - /// - /// The LU factored N by N matrix. Contains the inverse On exit. - /// The order of the square matrix . - /// The pivot indices of . - /// The work array. The array must have a length of at least N, - /// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal - /// work size value. - /// This is equivalent to the GETRI LAPACK routine. - public void LUInverseFactored(double[] a, int order, int[] ipiv, double[] work) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using LU factorization. - /// - /// The number of columns of B. - /// The square matrix A. - /// The order of the square matrix . - /// The B matrix. - /// This is equivalent to the GETRF and GETRS LAPACK routines. - public void LUSolve(int columnsOfB, double[] a, int order, double[] b) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using a previously factored A matrix. - /// - /// The number of columns of B. - /// The factored A matrix. - /// The order of the square matrix . - /// The pivot indices of . - /// The B matrix. - /// This is equivalent to the GETRS LAPACK routine. - public void LUSolveFactored(int columnsOfB, double[] a, int order, int[] ipiv, double[] b) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using LU factorization. - /// - /// How to transpose the matrix. - /// The number of columns of B. - /// The square matrix A. - /// The order of the square matrix . - /// The B matrix. - /// This is equivalent to the GETRF and GETRS LAPACK routines. - public void LUSolve(Transpose transposeA, int columnsOfB, double[] a, int order, double[] b) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using a previously factored A matrix. - /// - /// How to transpose the matrix. - /// The number of columns of B. - /// The factored A matrix. - /// The order of the square matrix . - /// The pivot indices of . - /// The B matrix. - /// This is equivalent to the GETRS LAPACK routine. - public void LUSolveFactored(Transpose transposeA, int columnsOfB, double[] a, int order, int[] ipiv, double[] b) - { - throw new NotImplementedException(); - } - - /// - /// Computes the Cholesky factorization of A. - /// - /// On entry, a square, positive definite matrix. On exit, the matrix is overwritten with the - /// the Cholesky factorization. - /// The number of rows or columns in the matrix. - /// This is equivalent to the POTRF LAPACK routine. - public void CholeskyFactor(double[] a, int order) - { - if (a == null) - { - throw new ArgumentNullException("a"); - } - - if (order < 1) - { - throw new ArgumentException(Resources.ArgumentMustBePositive, "order"); - } - - SafeNativeMethods.d_cholesky_factor(order, a); - } - - /// - /// Solves A*X=B for X using Cholesky factorization. - /// - /// The square, positive definite matrix A. - /// The number of rows and columns in A. - /// The B matrix. - /// The number of rows in the B matrix. - /// The number of columns in the B matrix. - /// This is equivalent to the POTRF add POTRS LAPACK routines. - /// - public void CholeskySolve(double[] a, int orderA, double[] b, int rowsB, int columnsB) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using a previously factored A matrix. - /// - /// The square, positive definite matrix A. - /// The number of rows and columns in A. - /// The B matrix. - /// The number of rows in the B matrix. - /// The number of columns in the B matrix. - /// This is equivalent to the POTRS LAPACK routine. - public void CholeskySolveFactored(double[] a, int orderA, double[] b, int rowsB, int columnsB) - { - throw new NotImplementedException(); - } - - /// - /// Computes the QR factorization of A. - /// - /// On entry, it is the M by N A matrix to factor. On exit, - /// it is overwritten with the R matrix of the QR factorization. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// On exit, A M by M matrix that holds the Q matrix of the - /// QR factorization. - /// This is similar to the GEQRF and ORGQR LAPACK routines. - public void QRFactor(double[] r, int rowsR, int columnsR, double[] q) - { - throw new NotImplementedException(); - } - - /// - /// Computes the QR factorization of A. - /// - /// On entry, it is the M by N A matrix to factor. On exit, - /// it is overwritten with the R matrix of the QR factorization. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// On exit, A M by M matrix that holds the Q matrix of the - /// QR factorization. - /// The work array. The array must have a length of at least N, - /// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal - /// work size value. - /// This is similar to the GEQRF and ORGQR LAPACK routines. - public void QRFactor(double[] r, int rowsR, int columnsR, double[] q, double[] work) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using QR factorization of A. - /// - /// On entry, it is the M by N A matrix to factor. On exit, - /// it is overwritten with the R matrix of the QR factorization. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// On exit, A M by M matrix that holds the Q matrix of the - /// QR factorization. - /// The B matrix. - /// The number of columns of B. - /// On exit, the solution matrix. - public void QRSolve(double[] r, int rowsR, int columnsR, double[] q, double[] b, int columnsB, double[] x) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using QR factorization of A. - /// - /// On entry, it is the M by N A matrix to factor. On exit, - /// it is overwritten with the R matrix of the QR factorization. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// On exit, A M by M matrix that holds the Q matrix of the - /// QR factorization. - /// The B matrix. - /// The number of columns of B. - /// On exit, the solution matrix. - /// The work array. The array must have a length of at least N, - /// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal - /// work size value. - public void QRSolve(double[] r, int rowsR, int columnsR, double[] q, double[] b, int columnsB, double[] x, double[] work) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using a previously QR factored matrix. - /// - /// The Q matrix obtained by calling . - /// The R matrix obtained by calling . - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// The B matrix. - /// The number of columns of B. - /// On exit, the solution matrix. - public void QRSolveFactored(double[] q, double[] r, int rowsR, int columnsR, double[] b, int columnsB, double[] x) - { - throw new NotImplementedException(); - } - - /// - /// Computes the singular value decomposition of A. - /// - /// Compute the singular U and VT vectors or not. - /// On entry, the M by N matrix to decompose. On exit, A may be overwritten. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// The singular values of A in ascending value. - /// If is true, on exit U contains the left - /// singular vectors. - /// If is true, on exit VT contains the transposed - /// right singular vectors. - /// This is equivalent to the GESVD LAPACK routine. - public void SingularValueDecomposition(bool computeVectors, double[] a, int rowsA, int columnsA, double[] s, double[] u, double[] vt) - { - throw new NotImplementedException(); - } - - /// - /// Computes the singular value decomposition of A. - /// - /// Compute the singular U and VT vectors or not. - /// On entry, the M by N matrix to decompose. On exit, A may be overwritten. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// The singular values of A in ascending value. - /// If is true, on exit U contains the left - /// singular vectors. - /// If is true, on exit VT contains the transposed - /// right singular vectors. - /// The work array. For real matrices, the work array should be at least - /// Max(3*Min(M, N) + Max(M, N), 5*Min(M,N)). For complex matrices, 2*Min(M, N) + Max(M, N). - /// On exit, work[0] contains the optimal work size value. - /// This is equivalent to the GESVD LAPACK routine. - public void SingularValueDecomposition(bool computeVectors, double[] a, int rowsA, int columnsA, double[] s, double[] u, double[] vt, double[] work) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using the singular value decomposition of A. - /// - /// On entry, the M by N matrix to decompose. On exit, A may be overwritten. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// The singular values of A in ascending value. - /// On exit U contains the left singular vectors. - /// On exit VT contains the transposed right singular vectors. - /// The B matrix. - /// The number of columns of B. - /// On exit, the solution matrix. - public void SvdSolve(double[] a, int rowsA, int columnsA, double[] s, double[] u, double[] vt, double[] b, int columnsB, double[] x) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using the singular value decomposition of A. - /// - /// On entry, the M by N matrix to decompose. On exit, A may be overwritten. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// The singular values of A in ascending value. - /// On exit U contains the left singular vectors. - /// On exit VT contains the transposed right singular vectors. - /// The B matrix. - /// The number of columns of B. - /// On exit, the solution matrix. - /// The work array. For real matrices, the work array should be at least - /// Max(3*Min(M, N) + Max(M, N), 5*Min(M,N)). For complex matrices, 2*Min(M, N) + Max(M, N). - /// On exit, work[0] contains the optimal work size value. - public void SvdSolve(double[] a, int rowsA, int columnsA, double[] s, double[] u, double[] vt, double[] b, int columnsB, double[] x, double[] work) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using a previously SVD decomposed matrix. - /// - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// The s values returned by . - /// The left singular vectors returned by . - /// The right singular vectors returned by . - /// The B matrix. - /// The number of columns of B. - /// On exit, the solution matrix. - public void SvdSolveFactored(int rowsA, int columnsA, double[] s, double[] u, double[] vt, double[] b, int columnsB, double[] x) - { - throw new NotImplementedException(); - } - - #endregion - - #region ILinearAlgebraProvider Members - - /// - /// Adds a scaled vector to another: y += alpha*x. - /// - /// The vector to update. - /// The value to scale by. - /// The vector to add to . - /// This equivalent to the AXPY BLAS routine. - public void AddVectorToScaledVector(float[] y, float alpha, float[] x) - { - if (y == null) - { - throw new ArgumentNullException("y"); - } - - if (x == null) - { - throw new ArgumentNullException("x"); - } - - if (y.Length != x.Length) - { - throw new ArgumentException(Resources.ArgumentVectorsSameLength); - } - - if (alpha == 0.0f) - { - return; - } - - SafeNativeMethods.s_axpy(y.Length, alpha, x, y); - } - - /// - /// Scales an array. Can be used to scale a vector and a matrix. - /// - /// The scalar. - /// The values to scale. - /// This is equivalent to the SCAL BLAS routine. - public void ScaleArray(float alpha, float[] x) - { - if (x == null) - { - throw new ArgumentNullException("x"); - } - - if (alpha == 1.0) - { - return; - } - - SafeNativeMethods.s_scale(x.Length, alpha, x); - } - - /// - /// Computes the dot product of x and y. - /// - /// The vector x. - /// The vector y. - /// The dot product of x and y. - /// This is equivalent to the DOT BLAS routine. - public float DotProduct(float[] x, float[] y) - { - if (y == null) - { - throw new ArgumentNullException("y"); - } - - if (x == null) - { - throw new ArgumentNullException("x"); - } - - if (x.Length != y.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - - return SafeNativeMethods.s_dot_product(x.Length, x, y); - } - - /// - /// Does a point wise add of two arrays z = x + y. This can be used - /// to add vectors or matrices. - /// - /// The array x. - /// The array y. - /// The result of the addition. - /// There is no equivalent BLAS routine, but many libraries - /// provide optimized (parallel and/or vectorized) versions of this - /// routine. - public void AddArrays(float[] x, float[] y, float[] result) - { - if (y == null) - { - throw new ArgumentNullException("y"); - } - - if (x == null) - { - throw new ArgumentNullException("x"); - } - - if (x.Length != y.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - - if (x.Length != result.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - - _managedProvider.AddArrays(x, y, result); - } - - /// - /// Does a point wise subtraction of two arrays z = x - y. This can be used - /// to subtract vectors or matrices. - /// - /// The array x. - /// The array y. - /// The result of the subtraction. - /// There is no equivalent BLAS routine, but many libraries - /// provide optimized (parallel and/or vectorized) versions of this - /// routine. - public void SubtractArrays(float[] x, float[] y, float[] result) - { - if (y == null) - { - throw new ArgumentNullException("y"); - } - - if (x == null) - { - throw new ArgumentNullException("x"); - } - - if (x.Length != y.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - - if (x.Length != result.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - - _managedProvider.SubtractArrays(x, y, result); - } - - /// - /// Does a point wise multiplication of two arrays z = x * y. This can be used - /// to multiple elements of vectors or matrices. - /// - /// The array x. - /// The array y. - /// The result of the point wise multiplication. - /// There is no equivalent BLAS routine, but many libraries - /// provide optimized (parallel and/or vectorized) versions of this - /// routine. - public void PointWiseMultiplyArrays(float[] x, float[] y, float[] result) - { - if (y == null) - { - throw new ArgumentNullException("y"); - } - - if (x == null) - { - throw new ArgumentNullException("x"); - } - - if (x.Length != y.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - - if (x.Length != result.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - - _managedProvider.PointWiseMultiplyArrays(x, y, result); - } - - /// - /// Computes the requested of the matrix. - /// - /// The type of norm to compute. - /// The number of rows in the matrix. - /// The number of columns in the matrix. - /// The matrix to compute the norm from. - /// - /// The requested of the matrix. - /// - public float MatrixNorm(Norm norm, int rows, int columns, float[] matrix) - { - throw new NotImplementedException(); - } - - /// - /// Computes the requested of the matrix. - /// - /// The type of norm to compute. - /// The number of rows in the matrix. - /// The number of columns in the matrix. - /// The matrix to compute the norm from. - /// The work array. Only used when - /// and needs to be have a length of at least M (number of rows of . - /// - /// The requested of the matrix. - /// - public float MatrixNorm(Norm norm, int rows, int columns, float[] matrix, float[] work) - { - throw new NotImplementedException(); - } - - /// - /// Multiples two matrices. result = x * y - /// - /// The x matrix. - /// The number of rows in the x matrix. - /// The number of columns in the x matrix. - /// The y matrix. - /// The number of rows in the y matrix. - /// The number of columns in the y matrix. - /// Where to store the result of the multiplication. - /// This is a simplified version of the BLAS GEMM routine with alpha - /// set to 1.0 and beta set to 0.0, and x and y are not transposed. - public void MatrixMultiply(float[] x, int rowsX, int columnsX, float[] y, int rowsY, int columnsY, float[] result) - { - MatrixMultiplyWithUpdate(Transpose.DontTranspose, Transpose.DontTranspose, 1.0f, x, rowsX, columnsX, y, rowsY, columnsY, 0.0f, result); - } - - /// - /// Multiplies two matrices and updates another with the result. c = alpha*op(a)*op(b) + beta*c - /// - /// How to transpose the matrix. - /// How to transpose the matrix. - /// The value to scale matrix. - /// The a matrix. - /// The number of rows in the matrix. - /// The number of columns in the matrix. - /// The b matrix - /// The number of rows in the matrix. - /// The number of columns in the matrix. - /// The value to scale the matrix. - /// The c matrix. - public void MatrixMultiplyWithUpdate(Transpose transposeA, Transpose transposeB, float alpha, float[] a, - int rowsA, int columnsA, float[] b, int rowsB, int columnsB, float beta, float[] c) - { - if (a == null) - { - throw new ArgumentNullException("a"); - } - - if (b == null) - { - throw new ArgumentNullException("b"); - } - - if (c == null) - { - throw new ArgumentNullException("c"); - } - - var m = transposeA == Transpose.DontTranspose ? rowsA : columnsA; - var n = transposeB == Transpose.DontTranspose ? columnsB : rowsB; - var k = transposeA == Transpose.DontTranspose ? columnsA : rowsA; - - if( c.Length != rowsA * columnsB) - { - throw new ArgumentException(Resources.ArgumentMatrixDimensions); - } - - if (columnsA != rowsB) - { - throw new ArgumentException(Resources.ArgumentMatrixDimensions); - } - - SafeNativeMethods.s_matrix_multiply(transposeA, transposeB, m, n, k, alpha, a, b, beta, c); - } - - /// - /// Computes the LUP factorization of A. P*A = L*U. - /// - /// An by matrix. The matrix is overwritten with the - /// the LU factorization on exit. The lower triangular factor L is stored in under the diagonal of (the diagonal is always 1.0 - /// for the L factor). The upper triangular factor U is stored on and above the diagonal of . - /// The order of the square matrix . - /// On exit, it contains the pivot indices. The size of the array must be . - /// This is equivalent to the GETRF LAPACK routine. - public void LUFactor(float[] data, int order, int[] ipiv) - { - throw new NotImplementedException(); - } - - /// - /// Computes the inverse of matrix using LU factorization. - /// - /// The N by N matrix to invert. Contains the inverse On exit. - /// The order of the square matrix . - /// This is equivalent to the GETRF and GETRI LAPACK routines. - public void LUInverse(float[] a, int order) - { - throw new NotImplementedException(); - } - - /// - /// Computes the inverse of a previously factored matrix. - /// - /// The LU factored N by N matrix. Contains the inverse On exit. - /// The order of the square matrix . - /// The pivot indices of . - /// This is equivalent to the GETRI LAPACK routine. - public void LUInverseFactored(float[] a, int order, int[] ipiv) - { - throw new NotImplementedException(); - } - - /// - /// Computes the inverse of matrix using LU factorization. - /// - /// The N by N matrix to invert. Contains the inverse On exit. - /// The order of the square matrix . - /// The work array. The array must have a length of at least N, - /// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal - /// work size value. - /// This is equivalent to the GETRF and GETRI LAPACK routines. - public void LUInverse(float[] a, int order, float[] work) - { - throw new NotImplementedException(); - } - - /// - /// Computes the inverse of a previously factored matrix. - /// - /// The LU factored N by N matrix. Contains the inverse On exit. - /// The order of the square matrix . - /// The pivot indices of . - /// The work array. The array must have a length of at least N, - /// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal - /// work size value. - /// This is equivalent to the GETRI LAPACK routine. - public void LUInverseFactored(float[] a, int order, int[] ipiv, float[] work) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using LU factorization. - /// - /// The number of columns of B. - /// The square matrix A. - /// The order of the square matrix . - /// The B matrix. - /// This is equivalent to the GETRF and GETRS LAPACK routines. - public void LUSolve(int columnsOfB, float[] a, int order, float[] b) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using a previously factored A matrix. - /// - /// The number of columns of B. - /// The factored A matrix. - /// The order of the square matrix . - /// The pivot indices of . - /// The B matrix. - /// This is equivalent to the GETRS LAPACK routine. - public void LUSolveFactored(int columnsOfB, float[] a, int order, int[] ipiv, float[] b) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using LU factorization. - /// - /// How to transpose the matrix. - /// The number of columns of B. - /// The square matrix A. - /// The order of the square matrix . - /// The B matrix. - /// This is equivalent to the GETRF and GETRS LAPACK routines. - public void LUSolve(Transpose transposeA, int columnsOfB, float[] a, int order, float[] b) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using a previously factored A matrix. - /// - /// How to transpose the matrix. - /// The number of columns of B. - /// The factored A matrix. - /// The order of the square matrix . - /// The pivot indices of . - /// The B matrix. - /// This is equivalent to the GETRS LAPACK routine. - public void LUSolveFactored(Transpose transposeA, int columnsOfB, float[] a, int order, int[] ipiv, float[] b) - { - throw new NotImplementedException(); - } - - /// - /// Computes the Cholesky factorization of A. - /// - /// On entry, a square, positive definite matrix. On exit, the matrix is overwritten with the - /// the Cholesky factorization. - /// The number of rows or columns in the matrix. - /// This is equivalent to the POTRF LAPACK routine. - public void CholeskyFactor(float[] a, int order) - { - if (a == null) - { - throw new ArgumentNullException("a"); - } - - if (order < 1) - { - throw new ArgumentException(Resources.ArgumentMustBePositive, "order"); - } - - SafeNativeMethods.s_cholesky_factor(order, a); - } - - /// - /// Solves A*X=B for X using Cholesky factorization. - /// - /// The square, positive definite matrix A. - /// The number of rows and columns in A. - /// The B matrix. - /// The number of rows in the B matrix. - /// The number of columns in the B matrix. - /// This is equivalent to the POTRF add POTRS LAPACK routines. - public void CholeskySolve(float[] a, int orderA, float[] b, int rowsB, int columnsB) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using a previously factored A matrix. - /// - /// The square, positive definite matrix A. - /// The number of rows and columns in A. - /// The B matrix. - /// The number of rows in the B matrix. - /// The number of columns in the B matrix. - /// This is equivalent to the POTRS LAPACK routine. - public void CholeskySolveFactored(float[] a, int orderA, float[] b, int rowsB, int columnsB) - { - throw new NotImplementedException(); - } - - /// - /// Computes the QR factorization of A. - /// - /// On entry, it is the M by N A matrix to factor. On exit, - /// it is overwritten with the R matrix of the QR factorization. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// On exit, A M by M matrix that holds the Q matrix of the - /// QR factorization. - /// This is similar to the GEQRF and ORGQR LAPACK routines. - public void QRFactor(float[] r, int rowsR, int columnsR, float[] q) - { - throw new NotImplementedException(); - } - - /// - /// Computes the QR factorization of A. - /// - /// On entry, it is the M by N A matrix to factor. On exit, - /// it is overwritten with the R matrix of the QR factorization. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// On exit, A M by M matrix that holds the Q matrix of the - /// QR factorization. - /// The work array. The array must have a length of at least N, - /// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal - /// work size value. - /// This is similar to the GEQRF and ORGQR LAPACK routines. - public void QRFactor(float[] r, int rowsR, int columnsR, float[] q, float[] work) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using QR factorization of A. - /// - /// On entry, it is the M by N A matrix to factor. On exit, - /// it is overwritten with the R matrix of the QR factorization. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// On exit, A M by M matrix that holds the Q matrix of the - /// QR factorization. - /// The B matrix. - /// The number of columns of B. - /// On exit, the solution matrix. - public void QRSolve(float[] r, int rowsR, int columnsR, float[] q, float[] b, int columnsB, float[] x) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using QR factorization of A. - /// - /// On entry, it is the M by N A matrix to factor. On exit, - /// it is overwritten with the R matrix of the QR factorization. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// On exit, A M by M matrix that holds the Q matrix of the - /// QR factorization. - /// The B matrix. - /// The number of columns of B. - /// On exit, the solution matrix. - /// The work array. The array must have a length of at least N, - /// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal - /// work size value. - public void QRSolve(float[] r, int rowsR, int columnsR, float[] q, float[] b, int columnsB, float[] x, float[] work) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using a previously QR factored matrix. - /// - /// The Q matrix obtained by calling . - /// The R matrix obtained by calling . - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// The B matrix. - /// The number of columns of B. - /// On exit, the solution matrix. - public void QRSolveFactored(float[] q, float[] r, int rowsR, int columnsR, float[] b, int columnsB, float[] x) - { - throw new NotImplementedException(); - } - - /// - /// Computes the singular value decomposition of A. - /// - /// Compute the singular U and VT vectors or not. - /// On entry, the M by N matrix to decompose. On exit, A may be overwritten. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// The singular values of A in ascending value. - /// If is true, on exit U contains the left - /// singular vectors. - /// If is true, on exit VT contains the transposed - /// right singular vectors. - /// This is equivalent to the GESVD LAPACK routine. - public void SingularValueDecomposition(bool computeVectors, float[] a, int rowsA, int columnsA, float[] s, float[] u, float[] vt) - { - throw new NotImplementedException(); - } - - /// - /// Computes the singular value decomposition of A. - /// - /// Compute the singular U and VT vectors or not. - /// On entry, the M by N matrix to decompose. On exit, A may be overwritten. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// The singular values of A in ascending value. - /// If is true, on exit U contains the left - /// singular vectors. - /// If is true, on exit VT contains the transposed - /// right singular vectors. - /// The work array. For real matrices, the work array should be at least - /// Max(3*Min(M, N) + Max(M, N), 5*Min(M,N)). For complex matrices, 2*Min(M, N) + Max(M, N). - /// On exit, work[0] contains the optimal work size value. - /// This is equivalent to the GESVD LAPACK routine. - public void SingularValueDecomposition(bool computeVectors, float[] a, int rowsA, int columnsA, float[] s, float[] u, float[] vt, float[] work) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using the singular value decomposition of A. - /// - /// On entry, the M by N matrix to decompose. On exit, A may be overwritten. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// The singular values of A in ascending value. - /// On exit U contains the left singular vectors. - /// On exit VT contains the transposed right singular vectors. - /// The B matrix. - /// The number of columns of B. - /// On exit, the solution matrix. - public void SvdSolve(float[] a, int rowsA, int columnsA, float[] s, float[] u, float[] vt, float[] b, int columnsB, float[] x) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using the singular value decomposition of A. - /// - /// On entry, the M by N matrix to decompose. On exit, A may be overwritten. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// The singular values of A in ascending value. - /// On exit U contains the left singular vectors. - /// On exit VT contains the transposed right singular vectors. - /// The B matrix. - /// The number of columns of B. - /// On exit, the solution matrix. - /// The work array. For real matrices, the work array should be at least - /// Max(3*Min(M, N) + Max(M, N), 5*Min(M,N)). For complex matrices, 2*Min(M, N) + Max(M, N). - /// On exit, work[0] contains the optimal work size value. - public void SvdSolve(float[] a, int rowsA, int columnsA, float[] s, float[] u, float[] vt, float[] b, int columnsB, float[] x, float[] work) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using a previously SVD decomposed matrix. - /// - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// The s values returned by . - /// The left singular vectors returned by . - /// The right singular vectors returned by . - /// The B matrix. - /// The number of columns of B. - /// On exit, the solution matrix. - public void SvdSolveFactored(int rowsA, int columnsA, float[] s, float[] u, float[] vt, float[] b, int columnsB, float[] x) - { - throw new NotImplementedException(); - } - - #endregion - - #region ILinearAlgebraProvider Members - - /// - /// Adds a scaled vector to another: y += alpha*x. - /// - /// The vector to update. - /// The value to scale by. - /// The vector to add to . - /// This equivalent to the AXPY BLAS routine. - public void AddVectorToScaledVector(Complex[] y, Complex alpha, Complex[] x) - { - if (y == null) - { - throw new ArgumentNullException("y"); - } - - if (x == null) - { - throw new ArgumentNullException("x"); - } - - if (y.Length != x.Length) - { - throw new ArgumentException(Resources.ArgumentVectorsSameLength); - } - - if (alpha.IsZero()) - { - return; - } - - SafeNativeMethods.z_axpy(y.Length, ref alpha, x, y); - } - - /// - /// Scales an array. Can be used to scale a vector and a matrix. - /// - /// The scalar. - /// The values to scale. - /// This is equivalent to the SCAL BLAS routine. - public void ScaleArray(Complex alpha, Complex[] x) - { - if (x == null) - { - throw new ArgumentNullException("x"); - } - - if (alpha.IsOne()) - { - return; - } - - SafeNativeMethods.z_scale(x.Length, ref alpha, x); - } - - /// - /// Computes the dot product of x and y. - /// - /// The vector x. - /// The vector y. - /// The dot product of x and y. - /// This is equivalent to the DOT BLAS routine. - public Complex DotProduct(Complex[] x, Complex[] y) - { - if (y == null) - { - throw new ArgumentNullException("y"); - } - - if (x == null) - { - throw new ArgumentNullException("x"); - } - - if (x.Length != y.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - - return SafeNativeMethods.z_dot_product(x.Length, x, y); - } - - /// - /// Does a point wise add of two arrays z = x + y. This can be used - /// to add vectors or matrices. - /// - /// The array x. - /// The array y. - /// The result of the addition. - /// There is no equivalent BLAS routine, but many libraries - /// provide optimized (parallel and/or vectorized) versions of this - /// routine. - public void AddArrays(Complex[] x, Complex[] y, Complex[] result) - { - if (y == null) - { - throw new ArgumentNullException("y"); - } - - if (x == null) - { - throw new ArgumentNullException("x"); - } - - if (x.Length != y.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - - if (x.Length != result.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - - _managedProvider.AddArrays(x, y, result); - } - - /// - /// Does a point wise subtraction of two arrays z = x - y. This can be used - /// to subtract vectors or matrices. - /// - /// The array x. - /// The array y. - /// The result of the subtraction. - /// There is no equivalent BLAS routine, but many libraries - /// provide optimized (parallel and/or vectorized) versions of this - /// routine. - public void SubtractArrays(Complex[] x, Complex[] y, Complex[] result) - { - if (y == null) - { - throw new ArgumentNullException("y"); - } - - if (x == null) - { - throw new ArgumentNullException("x"); - } - - if (x.Length != y.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - - if (x.Length != result.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - - _managedProvider.SubtractArrays(x, y, result); - } - - /// - /// Does a point wise multiplication of two arrays z = x * y. This can be used - /// to multiple elements of vectors or matrices. - /// - /// The array x. - /// The array y. - /// The result of the point wise multiplication. - /// There is no equivalent BLAS routine, but many libraries - /// provide optimized (parallel and/or vectorized) versions of this - /// routine. - public void PointWiseMultiplyArrays(Complex[] x, Complex[] y, Complex[] result) - { - if (y == null) - { - throw new ArgumentNullException("y"); - } - - if (x == null) - { - throw new ArgumentNullException("x"); - } - - if (x.Length != y.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - - if (x.Length != result.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - - _managedProvider.PointWiseMultiplyArrays(x, y, result); - } - - /// - /// Computes the requested of the matrix. - /// - /// The type of norm to compute. - /// The number of rows in the matrix. - /// The number of columns in the matrix. - /// The matrix to compute the norm from. - /// - /// The requested of the matrix. - /// - public Complex MatrixNorm(Norm norm, int rows, int columns, Complex[] matrix) - { - throw new NotImplementedException(); - } - - /// - /// Computes the requested of the matrix. - /// - /// The type of norm to compute. - /// The number of rows in the matrix. - /// The number of columns in the matrix. - /// The matrix to compute the norm from. - /// The work array. Only used when - /// and needs to be have a length of at least M (number of rows of . - /// - /// The requested of the matrix. - /// - public Complex MatrixNorm(Norm norm, int rows, int columns, Complex[] matrix, Complex[] work) - { - throw new NotImplementedException(); - } - - /// - /// Multiples two matrices. result = x * y - /// - /// The x matrix. - /// The number of rows in the x matrix. - /// The number of columns in the x matrix. - /// The y matrix. - /// The number of rows in the y matrix. - /// The number of columns in the y matrix. - /// Where to store the result of the multiplication. - /// This is a simplified version of the BLAS GEMM routine with alpha - /// set to 1.0 and beta set to 0.0, and x and y are not transposed. - public void MatrixMultiply(Complex[] x, int rowsX, int columnsX, Complex[] y, int rowsY, int columnsY, Complex[] result) - { - MatrixMultiplyWithUpdate(Transpose.DontTranspose, Transpose.DontTranspose, Complex.One, x, rowsX, columnsX, y, rowsY, columnsY, Complex.Zero, result); - } - - /// - /// Multiplies two matrices and updates another with the result. c = alpha*op(a)*op(b) + beta*c - /// - /// How to transpose the matrix. - /// How to transpose the matrix. - /// The value to scale matrix. - /// The a matrix. - /// The number of rows in the matrix. - /// The number of columns in the matrix. - /// The b matrix - /// The number of rows in the matrix. - /// The number of columns in the matrix. - /// The value to scale the matrix. - /// The c matrix. - public void MatrixMultiplyWithUpdate(Transpose transposeA, Transpose transposeB, Complex alpha, Complex[] a, - int rowsA, int columnsA, Complex[] b, int rowsB, int columnsB, Complex beta, Complex[] c) - { - if (a == null) - { - throw new ArgumentNullException("a"); - } - - if (b == null) - { - throw new ArgumentNullException("b"); - } - - if (c == null) - { - throw new ArgumentNullException("c"); - } - - var m = transposeA == Transpose.DontTranspose ? rowsA : columnsA; - var n = transposeB == Transpose.DontTranspose ? columnsB : rowsB; - var k = transposeA == Transpose.DontTranspose ? columnsA : rowsA; - - if( c.Length != rowsA * columnsB) - { - throw new ArgumentException(Resources.ArgumentMatrixDimensions); - } - - if (columnsA != rowsB) - { - throw new ArgumentException(Resources.ArgumentMatrixDimensions); - } - - SafeNativeMethods.z_matrix_multiply(transposeA, transposeB, m, n, k, ref alpha, a, b, ref beta, c); - } - - /// - /// Computes the LUP factorization of A. P*A = L*U. - /// - /// An by matrix. The matrix is overwritten with the - /// the LU factorization on exit. The lower triangular factor L is stored in under the diagonal of (the diagonal is always 1.0 - /// for the L factor). The upper triangular factor U is stored on and above the diagonal of . - /// The order of the square matrix . - /// On exit, it contains the pivot indices. The size of the array must be . - /// This is equivalent to the GETRF LAPACK routine. - public void LUFactor(Complex[] data, int order, int[] ipiv) - { - throw new NotImplementedException(); - } - - /// - /// Computes the inverse of matrix using LU factorization. - /// - /// The N by N matrix to invert. Contains the inverse On exit. - /// The order of the square matrix . - /// This is equivalent to the GETRF and GETRI LAPACK routines. - public void LUInverse(Complex[] a, int order) - { - throw new NotImplementedException(); - } - - /// - /// Computes the inverse of a previously factored matrix. - /// - /// The LU factored N by N matrix. Contains the inverse On exit. - /// The order of the square matrix . - /// The pivot indices of . - /// This is equivalent to the GETRI LAPACK routine. - public void LUInverseFactored(Complex[] a, int order, int[] ipiv) - { - throw new NotImplementedException(); - } - - /// - /// Computes the inverse of matrix using LU factorization. - /// - /// The N by N matrix to invert. Contains the inverse On exit. - /// The order of the square matrix . - /// The work array. The array must have a length of at least N, - /// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal - /// work size value. - /// This is equivalent to the GETRF and GETRI LAPACK routines. - public void LUInverse(Complex[] a, int order, Complex[] work) - { - throw new NotImplementedException(); - } - - /// - /// Computes the inverse of a previously factored matrix. - /// - /// The LU factored N by N matrix. Contains the inverse On exit. - /// The order of the square matrix . - /// The pivot indices of . - /// The work array. The array must have a length of at least N, - /// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal - /// work size value. - /// This is equivalent to the GETRI LAPACK routine. - public void LUInverseFactored(Complex[] a, int order, int[] ipiv, Complex[] work) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using LU factorization. - /// - /// The number of columns of B. - /// The square matrix A. - /// The order of the square matrix . - /// The B matrix. - /// This is equivalent to the GETRF and GETRS LAPACK routines. - public void LUSolve(int columnsOfB, Complex[] a, int order, Complex[] b) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using a previously factored A matrix. - /// - /// The number of columns of B. - /// The factored A matrix. - /// The order of the square matrix . - /// The pivot indices of . - /// The B matrix. - /// This is equivalent to the GETRS LAPACK routine. - public void LUSolveFactored(int columnsOfB, Complex[] a, int order, int[] ipiv, Complex[] b) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using LU factorization. - /// - /// How to transpose the matrix. - /// The number of columns of B. - /// The square matrix A. - /// The order of the square matrix . - /// The B matrix. - /// This is equivalent to the GETRF and GETRS LAPACK routines. - public void LUSolve(Transpose transposeA, int columnsOfB, Complex[] a, int order, Complex[] b) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using a previously factored A matrix. - /// - /// How to transpose the matrix. - /// The number of columns of B. - /// The factored A matrix. - /// The order of the square matrix . - /// The pivot indices of . - /// The B matrix. - /// This is equivalent to the GETRS LAPACK routine. - public void LUSolveFactored(Transpose transposeA, int columnsOfB, Complex[] a, int order, int[] ipiv, Complex[] b) - { - throw new NotImplementedException(); - } - - /// - /// Computes the Cholesky factorization of A. - /// - /// On entry, a square, positive definite matrix. On exit, the matrix is overwritten with the - /// the Cholesky factorization. - /// The number of rows or columns in the matrix. - /// This is equivalent to the POTRF LAPACK routine. - public void CholeskyFactor(Complex[] a, int order) - { - if (a == null) - { - throw new ArgumentNullException("a"); - } - - if (order < 1) - { - throw new ArgumentException(Resources.ArgumentMustBePositive, "order"); - } - - SafeNativeMethods.z_cholesky_factor(order, a); - } - - /// - /// Solves A*X=B for X using Cholesky factorization. - /// - /// The square, positive definite matrix A. - /// The number of rows and columns in A. - /// The B matrix. - /// The number of rows in the B matrix. - /// The number of columns in the B matrix. - /// This is equivalent to the POTRF add POTRS LAPACK routines. - public void CholeskySolve(Complex[] a, int orderA, Complex[] b, int rowsB, int columnsB) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using a previously factored A matrix. - /// - /// The square, positive definite matrix A. - /// The number of rows and columns in A. - /// The B matrix. - /// The number of rows in the B matrix. - /// The number of columns in the B matrix. - /// This is equivalent to the POTRS LAPACK routine. - public void CholeskySolveFactored(Complex[] a, int orderA, Complex[] b, int rowsB, int columnsB) - { - throw new NotImplementedException(); - } - - /// - /// Computes the QR factorization of A. - /// - /// On entry, it is the M by N A matrix to factor. On exit, - /// it is overwritten with the R matrix of the QR factorization. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// On exit, A M by M matrix that holds the Q matrix of the - /// QR factorization. - /// This is similar to the GEQRF and ORGQR LAPACK routines. - public void QRFactor(Complex[] r, int rowsR, int columnsR, Complex[] q) - { - throw new NotImplementedException(); - } - - /// - /// Computes the QR factorization of A. - /// - /// On entry, it is the M by N A matrix to factor. On exit, - /// it is overwritten with the R matrix of the QR factorization. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// On exit, A M by M matrix that holds the Q matrix of the - /// QR factorization. - /// The work array. The array must have a length of at least N, - /// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal - /// work size value. - /// This is similar to the GEQRF and ORGQR LAPACK routines. - public void QRFactor(Complex[] r, int rowsR, int columnsR, Complex[] q, Complex[] work) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using QR factorization of A. - /// - /// On entry, it is the M by N A matrix to factor. On exit, - /// it is overwritten with the R matrix of the QR factorization. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// On exit, A M by M matrix that holds the Q matrix of the - /// QR factorization. - /// The B matrix. - /// The number of columns of B. - /// On exit, the solution matrix. - public void QRSolve(Complex[] r, int rowsR, int columnsR, Complex[] q, Complex[] b, int columnsB, Complex[] x) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using QR factorization of A. - /// - /// On entry, it is the M by N A matrix to factor. On exit, - /// it is overwritten with the R matrix of the QR factorization. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// On exit, A M by M matrix that holds the Q matrix of the - /// QR factorization. - /// The B matrix. - /// The number of columns of B. - /// On exit, the solution matrix. - /// The work array. The array must have a length of at least N, - /// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal - /// work size value. - public void QRSolve(Complex[] r, int rowsR, int columnsR, Complex[] q, Complex[] b, int columnsB, Complex[] x, Complex[] work) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using a previously QR factored matrix. - /// - /// The Q matrix obtained by calling . - /// The R matrix obtained by calling . - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// The B matrix. - /// The number of columns of B. - /// On exit, the solution matrix. - public void QRSolveFactored(Complex[] q, Complex[] r, int rowsR, int columnsR, Complex[] b, int columnsB, Complex[] x) - { - throw new NotImplementedException(); - } - - /// - /// Computes the singular value decomposition of A. - /// - /// Compute the singular U and VT vectors or not. - /// On entry, the M by N matrix to decompose. On exit, A may be overwritten. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// The singular values of A in ascending value. - /// If is true, on exit U contains the left - /// singular vectors. - /// If is true, on exit VT contains the transposed - /// right singular vectors. - /// This is equivalent to the GESVD LAPACK routine. - public void SingularValueDecomposition(bool computeVectors, Complex[] a, int rowsA, int columnsA, Complex[] s, Complex[] u, Complex[] vt) - { - throw new NotImplementedException(); - } - - /// - /// Computes the singular value decomposition of A. - /// - /// Compute the singular U and VT vectors or not. - /// On entry, the M by N matrix to decompose. On exit, A may be overwritten. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// The singular values of A in ascending value. - /// If is true, on exit U contains the left - /// singular vectors. - /// If is true, on exit VT contains the transposed - /// right singular vectors. - /// The work array. For real matrices, the work array should be at least - /// Max(3*Min(M, N) + Max(M, N), 5*Min(M,N)). For complex matrices, 2*Min(M, N) + Max(M, N). - /// On exit, work[0] contains the optimal work size value. - /// This is equivalent to the GESVD LAPACK routine. - public void SingularValueDecomposition(bool computeVectors, Complex[] a, int rowsA, int columnsA, Complex[] s, Complex[] u, Complex[] vt, Complex[] work) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using the singular value decomposition of A. - /// - /// On entry, the M by N matrix to decompose. On exit, A may be overwritten. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// The singular values of A in ascending value. - /// On exit U contains the left singular vectors. - /// On exit VT contains the transposed right singular vectors. - /// The B matrix. - /// The number of columns of B. - /// On exit, the solution matrix. - public void SvdSolve(Complex[] a, int rowsA, int columnsA, Complex[] s, Complex[] u, Complex[] vt, Complex[] b, int columnsB, Complex[] x) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using the singular value decomposition of A. - /// - /// On entry, the M by N matrix to decompose. On exit, A may be overwritten. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// The singular values of A in ascending value. - /// On exit U contains the left singular vectors. - /// On exit VT contains the transposed right singular vectors. - /// The B matrix. - /// The number of columns of B. - /// On exit, the solution matrix. - /// The work array. For real matrices, the work array should be at least - /// Max(3*Min(M, N) + Max(M, N), 5*Min(M,N)). For complex matrices, 2*Min(M, N) + Max(M, N). - /// On exit, work[0] contains the optimal work size value. - public void SvdSolve(Complex[] a, int rowsA, int columnsA, Complex[] s, Complex[] u, Complex[] vt, Complex[] b, int columnsB, Complex[] x, Complex[] work) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using a previously SVD decomposed matrix. - /// - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// The s values returned by . - /// The left singular vectors returned by . - /// The right singular vectors returned by . - /// The B matrix. - /// The number of columns of B. - /// On exit, the solution matrix. - public void SvdSolveFactored(int rowsA, int columnsA, Complex[] s, Complex[] u, Complex[] vt, Complex[] b, int columnsB, Complex[] x) - { - throw new NotImplementedException(); - } - - #endregion - - #region ILinearAlgebraProvider Members - - /// - /// Adds a scaled vector to another: y += alpha*x. - /// - /// The vector to update. - /// The value to scale by. - /// The vector to add to . - /// This equivalent to the AXPY BLAS routine. - public void AddVectorToScaledVector(Complex32[] y, Complex32 alpha, Complex32[] x) - { - if (y == null) - { - throw new ArgumentNullException("y"); - } - - if (x == null) - { - throw new ArgumentNullException("x"); - } - - if (y.Length != x.Length) - { - throw new ArgumentException(Resources.ArgumentVectorsSameLength); - } - - if (alpha.IsZero()) - { - return; - } - - SafeNativeMethods.c_axpy(y.Length, ref alpha, x, y); - } - - /// - /// Scales an array. Can be used to scale a vector and a matrix. - /// - /// The scalar. - /// The values to scale. - /// This is equivalent to the SCAL BLAS routine. - public void ScaleArray(Complex32 alpha, Complex32[] x) - { - if (x == null) - { - throw new ArgumentNullException("x"); - } - - if (alpha.IsOne()) - { - return; - } - - SafeNativeMethods.c_scale(x.Length, ref alpha, x); - } - - /// - /// Computes the dot product of x and y. - /// - /// The vector x. - /// The vector y. - /// The dot product of x and y. - /// This is equivalent to the DOT BLAS routine. - public Complex32 DotProduct(Complex32[] x, Complex32[] y) - { - if (y == null) - { - throw new ArgumentNullException("y"); - } - - if (x == null) - { - throw new ArgumentNullException("x"); - } - - if (x.Length != y.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - - return SafeNativeMethods.c_dot_product(x.Length, x, y); - } - - /// - /// Does a point wise add of two arrays z = x + y. This can be used - /// to add vectors or matrices. - /// - /// The array x. - /// The array y. - /// The result of the addition. - /// There is no equivalent BLAS routine, but many libraries - /// provide optimized (parallel and/or vectorized) versions of this - /// routine. - public void AddArrays(Complex32[] x, Complex32[] y, Complex32[] result) - { - if (y == null) - { - throw new ArgumentNullException("y"); - } - - if (x == null) - { - throw new ArgumentNullException("x"); - } - - if (x.Length != y.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - - if (x.Length != result.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - - _managedProvider.AddArrays(x, y, result); - } - - /// - /// Does a point wise subtraction of two arrays z = x - y. This can be used - /// to subtract vectors or matrices. - /// - /// The array x. - /// The array y. - /// The result of the subtraction. - /// There is no equivalent BLAS routine, but many libraries - /// provide optimized (parallel and/or vectorized) versions of this - /// routine. - public void SubtractArrays(Complex32[] x, Complex32[] y, Complex32[] result) - { - if (y == null) - { - throw new ArgumentNullException("y"); - } - - if (x == null) - { - throw new ArgumentNullException("x"); - } - - if (x.Length != y.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - - if (x.Length != result.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - - _managedProvider.SubtractArrays(x, y, result); - } - - /// - /// Does a point wise multiplication of two arrays z = x * y. This can be used - /// to multiple elements of vectors or matrices. - /// - /// The array x. - /// The array y. - /// The result of the point wise multiplication. - /// There is no equivalent BLAS routine, but many libraries - /// provide optimized (parallel and/or vectorized) versions of this - /// routine. - public void PointWiseMultiplyArrays(Complex32[] x, Complex32[] y, Complex32[] result) - { - if (y == null) - { - throw new ArgumentNullException("y"); - } - - if (x == null) - { - throw new ArgumentNullException("x"); - } - - if (x.Length != y.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - - if (x.Length != result.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - - _managedProvider.PointWiseMultiplyArrays(x, y, result); - } - - /// - /// Computes the requested of the matrix. - /// - /// The type of norm to compute. - /// The number of rows. - /// The number of columns. - /// The matrix to compute the norm from. - /// - /// The requested of the matrix. - /// - public Complex32 MatrixNorm(Norm norm, int rows, int columns, Complex32[] matrix) - { - throw new NotImplementedException(); - } - - /// - /// Computes the requested of the matrix. - /// - /// The type of norm to compute. - /// The number of rows. - /// The number of columns. - /// The matrix to compute the norm from. - /// The work array. Only used when - /// and needs to be have a length of at least M (number of rows of . - /// - /// The requested of the matrix. - /// - public Complex32 MatrixNorm(Norm norm, int rows, int columns, Complex32[] matrix, Complex32[] work) - { - throw new NotImplementedException(); - } - - /// - /// Multiples two matrices. result = x * y - /// - /// The x matrix. - /// The number of rows in the x matrix. - /// The number of columns in the x matrix. - /// The y matrix. - /// The number of rows in the y matrix. - /// The number of columns in the y matrix. - /// Where to store the result of the multiplication. - /// This is a simplified version of the BLAS GEMM routine with alpha - /// set to 1.0 and beta set to 0.0, and x and y are not transposed. - public void MatrixMultiply(Complex32[] x, int rowsX, int columnsX, Complex32[] y, int rowsY, int columnsY, Complex32[] result) - { - MatrixMultiplyWithUpdate(Transpose.DontTranspose, Transpose.DontTranspose, Complex32.One, x, rowsX, columnsX, y, rowsY, columnsY, Complex32.Zero, result); - } - - /// - /// Multiplies two matrices and updates another with the result. c = alpha*op(a)*op(b) + beta*c - /// - /// How to transpose the matrix. - /// How to transpose the matrix. - /// The value to scale matrix. - /// The a matrix. - /// The number of rows in the matrix. - /// The number of columns in the matrix. - /// The b matrix - /// The number of rows in the matrix. - /// The number of columns in the matrix. - /// The value to scale the matrix. - /// The c matrix. - public void MatrixMultiplyWithUpdate(Transpose transposeA, Transpose transposeB, Complex32 alpha, Complex32[] a, - int rowsA, int columnsA, Complex32[] b, int rowsB, int columnsB, Complex32 beta, Complex32[] c) - { - if (a == null) - { - throw new ArgumentNullException("a"); - } - - if (b == null) - { - throw new ArgumentNullException("b"); - } - - if (c == null) - { - throw new ArgumentNullException("c"); - } - - var m = transposeA == Transpose.DontTranspose ? rowsA : columnsA; - var n = transposeB == Transpose.DontTranspose ? columnsB : rowsB; - var k = transposeA == Transpose.DontTranspose ? columnsA : rowsA; - - if( c.Length != rowsA * columnsB) - { - throw new ArgumentException(Resources.ArgumentMatrixDimensions); - } - - if (columnsA != rowsB) - { - throw new ArgumentException(Resources.ArgumentMatrixDimensions); - } - - SafeNativeMethods.c_matrix_multiply(transposeA, transposeB, m, n, k, ref alpha, a, b, ref beta, c); - } - - /// - /// Computes the LUP factorization of A. P*A = L*U. - /// - /// An by matrix. The matrix is overwritten with the - /// the LU factorization on exit. The lower triangular factor L is stored in under the diagonal of (the diagonal is always 1.0 - /// for the L factor). The upper triangular factor U is stored on and above the diagonal of . - /// The order of the square matrix . - /// On exit, it contains the pivot indices. The size of the array must be . - /// This is equivalent to the GETRF LAPACK routine. - public void LUFactor(Complex32[] data, int order, int[] ipiv) - { - throw new NotImplementedException(); - } - - /// - /// Computes the inverse of matrix using LU factorization. - /// - /// The N by N matrix to invert. Contains the inverse On exit. - /// The order of the square matrix . - /// This is equivalent to the GETRF and GETRI LAPACK routines. - public void LUInverse(Complex32[] a, int order) - { - throw new NotImplementedException(); - } - - /// - /// Computes the inverse of a previously factored matrix. - /// - /// The LU factored N by N matrix. Contains the inverse On exit. - /// The order of the square matrix . - /// The pivot indices of . - /// This is equivalent to the GETRI LAPACK routine. - public void LUInverseFactored(Complex32[] a, int order, int[] ipiv) - { - throw new NotImplementedException(); - } - - /// - /// Computes the inverse of matrix using LU factorization. - /// - /// The N by N matrix to invert. Contains the inverse On exit. - /// The order of the square matrix . - /// The work array. The array must have a length of at least N, - /// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal - /// work size value. - /// This is equivalent to the GETRF and GETRI LAPACK routines. - public void LUInverse(Complex32[] a, int order, Complex32[] work) - { - throw new NotImplementedException(); - } - - /// - /// Computes the inverse of a previously factored matrix. - /// - /// The LU factored N by N matrix. Contains the inverse On exit. - /// The order of the square matrix . - /// The pivot indices of . - /// The work array. The array must have a length of at least N, - /// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal - /// work size value. - /// This is equivalent to the GETRI LAPACK routine. - public void LUInverseFactored(Complex32[] a, int order, int[] ipiv, Complex32[] work) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using LU factorization. - /// - /// The number of columns of B. - /// The square matrix A. - /// The order of the square matrix . - /// The B matrix. - /// This is equivalent to the GETRF and GETRS LAPACK routines. - public void LUSolve(int columnsOfB, Complex32[] a, int order, Complex32[] b) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using a previously factored A matrix. - /// - /// The number of columns of B. - /// The factored A matrix. - /// The order of the square matrix . - /// The pivot indices of . - /// The B matrix. - /// This is equivalent to the GETRS LAPACK routine. - public void LUSolveFactored(int columnsOfB, Complex32[] a, int order, int[] ipiv, Complex32[] b) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using LU factorization. - /// - /// How to transpose the matrix. - /// The number of columns of B. - /// The square matrix A. - /// The order of the square matrix . - /// The B matrix. - /// This is equivalent to the GETRF and GETRS LAPACK routines. - public void LUSolve(Transpose transposeA, int columnsOfB, Complex32[] a, int order, Complex32[] b) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using a previously factored A matrix. - /// - /// How to transpose the matrix. - /// The number of columns of B. - /// The factored A matrix. - /// The order of the square matrix . - /// The pivot indices of . - /// The B matrix. - /// This is equivalent to the GETRS LAPACK routine. - public void LUSolveFactored(Transpose transposeA, int columnsOfB, Complex32[] a, int order, int[] ipiv, Complex32[] b) - { - throw new NotImplementedException(); - } - - /// - /// Computes the Cholesky factorization of A. - /// - /// On entry, a square, positive definite matrix. On exit, the matrix is overwritten with the - /// the Cholesky factorization. - /// The number of rows or columns in the matrix. - /// This is equivalent to the POTRF LAPACK routine. - public void CholeskyFactor(Complex32[] a, int order) - { - if (a == null) - { - throw new ArgumentNullException("a"); - } - - if (order < 1) - { - throw new ArgumentException(Resources.ArgumentMustBePositive, "order"); - } - - SafeNativeMethods.c_cholesky_factor(order, a); - } - - /// - /// Solves A*X=B for X using Cholesky factorization. - /// - /// The square, positive definite matrix A. - /// The number of rows and columns in A. - /// The B matrix. - /// The number of rows in the B matrix. - /// The number of columns in the B matrix. - /// This is equivalent to the POTRF add POTRS LAPACK routines. - public void CholeskySolve(Complex32[] a, int orderA, Complex32[] b, int rowsB, int columnsB) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using a previously factored A matrix. - /// - /// The square, positive definite matrix A. - /// The number of rows and columns in A. - /// The B matrix. - /// The number of rows in the B matrix. - /// The number of columns in the B matrix. - /// This is equivalent to the POTRS LAPACK routine. - public void CholeskySolveFactored(Complex32[] a, int orderA, Complex32[] b, int rowsB, int columnsB) - { - throw new NotImplementedException(); - } - - /// - /// Computes the QR factorization of A. - /// - /// On entry, it is the M by N A matrix to factor. On exit, - /// it is overwritten with the R matrix of the QR factorization. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// On exit, A M by M matrix that holds the Q matrix of the - /// QR factorization. - /// This is similar to the GEQRF and ORGQR LAPACK routines. - public void QRFactor(Complex32[] r, int rowsR, int columnsR, Complex32[] q) - { - throw new NotImplementedException(); - } - - /// - /// Computes the QR factorization of A. - /// - /// On entry, it is the M by N A matrix to factor. On exit, - /// it is overwritten with the R matrix of the QR factorization. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// On exit, A M by M matrix that holds the Q matrix of the - /// QR factorization. - /// The work array. The array must have a length of at least N, - /// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal - /// work size value. - /// This is similar to the GEQRF and ORGQR LAPACK routines. - public void QRFactor(Complex32[] r, int rowsR, int columnsR, Complex32[] q, Complex32[] work) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using QR factorization of A. - /// - /// On entry, it is the M by N A matrix to factor. On exit, - /// it is overwritten with the R matrix of the QR factorization. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// On exit, A M by M matrix that holds the Q matrix of the - /// QR factorization. - /// The B matrix. - /// The number of columns of B. - /// On exit, the solution matrix. - public void QRSolve(Complex32[] r, int rowsR, int columnsR, Complex32[] q, Complex32[] b, int columnsB, Complex32[] x) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using QR factorization of A. - /// - /// On entry, it is the M by N A matrix to factor. On exit, - /// it is overwritten with the R matrix of the QR factorization. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// On exit, A M by M matrix that holds the Q matrix of the - /// QR factorization. - /// The B matrix. - /// The number of columns of B. - /// On exit, the solution matrix. - /// The work array. The array must have a length of at least N, - /// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal - /// work size value. - public void QRSolve(Complex32[] r, int rowsR, int columnsR, Complex32[] q, Complex32[] b, int columnsB, Complex32[] x, Complex32[] work) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using a previously QR factored matrix. - /// - /// The Q matrix obtained by calling . - /// The R matrix obtained by calling . - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// The B matrix. - /// The number of columns of B. - /// On exit, the solution matrix. - public void QRSolveFactored(Complex32[] q, Complex32[] r, int rowsR, int columnsR, Complex32[] b, int columnsB, Complex32[] x) - { - throw new NotImplementedException(); - } - - /// - /// Computes the singular value decomposition of A. - /// - /// Compute the singular U and VT vectors or not. - /// On entry, the M by N matrix to decompose. On exit, A may be overwritten. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// The singular values of A in ascending value. - /// If is true, on exit U contains the left - /// singular vectors. - /// If is true, on exit VT contains the transposed - /// right singular vectors. - /// This is equivalent to the GESVD LAPACK routine. - public void SingularValueDecomposition(bool computeVectors, Complex32[] a, int rowsA, int columnsA, Complex32[] s, Complex32[] u, Complex32[] vt) - { - throw new NotImplementedException(); - } - - /// - /// Computes the singular value decomposition of A. - /// - /// Compute the singular U and VT vectors or not. - /// On entry, the M by N matrix to decompose. On exit, A may be overwritten. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// The singular values of A in ascending value. - /// If is true, on exit U contains the left - /// singular vectors. - /// If is true, on exit VT contains the transposed - /// right singular vectors. - /// The work array. For real matrices, the work array should be at least - /// Max(3*Min(M, N) + Max(M, N), 5*Min(M,N)). For complex matrices, 2*Min(M, N) + Max(M, N). - /// On exit, work[0] contains the optimal work size value. - /// This is equivalent to the GESVD LAPACK routine. - public void SingularValueDecomposition(bool computeVectors, Complex32[] a, int rowsA, int columnsA, Complex32[] s, Complex32[] u, Complex32[] vt, Complex32[] work) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using the singular value decomposition of A. - /// - /// On entry, the M by N matrix to decompose. On exit, A may be overwritten. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// The singular values of A in ascending value. - /// On exit U contains the left singular vectors. - /// On exit VT contains the transposed right singular vectors. - /// The B matrix. - /// The number of columns of B. - /// On exit, the solution matrix. - public void SvdSolve(Complex32[] a, int rowsA, int columnsA, Complex32[] s, Complex32[] u, Complex32[] vt, Complex32[] b, int columnsB, Complex32[] x) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using the singular value decomposition of A. - /// - /// On entry, the M by N matrix to decompose. On exit, A may be overwritten. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// The singular values of A in ascending value. - /// On exit U contains the left singular vectors. - /// On exit VT contains the transposed right singular vectors. - /// The B matrix. - /// The number of columns of B. - /// On exit, the solution matrix. - /// The work array. For real matrices, the work array should be at least - /// Max(3*Min(M, N) + Max(M, N), 5*Min(M,N)). For complex matrices, 2*Min(M, N) + Max(M, N). - /// On exit, work[0] contains the optimal work size value. - public void SvdSolve(Complex32[] a, int rowsA, int columnsA, Complex32[] s, Complex32[] u, Complex32[] vt, Complex32[] b, int columnsB, Complex32[] x, Complex32[] work) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using a previously SVD decomposed matrix. - /// - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// The s values returned by . - /// The left singular vectors returned by . - /// The right singular vectors returned by . - /// The B matrix. - /// The number of columns of B. - /// On exit, the solution matrix. - public void SvdSolveFactored(int rowsA, int columnsA, Complex32[] s, Complex32[] u, Complex32[] vt, Complex32[] b, int columnsB, Complex32[] x) - { - throw new NotImplementedException(); - } - - #endregion - } -} \ No newline at end of file diff --git a/src/Numerics/Algorithms/LinearAlgebra/Atlas/AtlasLinearAlgebraProvider.tt b/src/Numerics/Algorithms/LinearAlgebra/Atlas/AtlasLinearAlgebraProvider.tt deleted file mode 100644 index c355ef98..00000000 --- a/src/Numerics/Algorithms/LinearAlgebra/Atlas/AtlasLinearAlgebraProvider.tt +++ /dev/null @@ -1,4 +0,0 @@ -<#@ template language="C#" debug="true" #> -<#@ output extenstion="cs" #> -<# string library = "Atlas";#> -<#@ include file="..\NativeAlgebraProvider.include" #> \ No newline at end of file diff --git a/src/Numerics/Algorithms/LinearAlgebra/Atlas/SafeNativeMethods.cs b/src/Numerics/Algorithms/LinearAlgebra/Atlas/SafeNativeMethods.cs deleted file mode 100644 index 394d79ad..00000000 --- a/src/Numerics/Algorithms/LinearAlgebra/Atlas/SafeNativeMethods.cs +++ /dev/null @@ -1,121 +0,0 @@ -// -// Math.NET Numerics, part of the Math.NET Project -// http://mathnet.opensourcedotnet.info -// -// Copyright (c) 2009 Math.NET -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. -// - -/* This file is automatically generated - do not modify it. - Change SafeNativeMethods.include instead. - Last generated on UTC 2010-06-27 13:08:33Z -*/ - -using System.Numerics; -using System.Runtime.InteropServices; -using System.Security; - -namespace MathNet.Numerics.Algorithms.LinearAlgebra.Atlas -{ - /// - /// P/Invoke methods to the native math libraries. - /// - [SuppressUnmanagedCodeSecurity] - internal static class SafeNativeMethods - { - /// - /// Name of the native DLL. - /// - private const string DllName = "MathNET.Numerics.ATLAS.dll"; - - #region BLAS - - [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] - internal static extern void s_axpy(int n, float alpha, float[] x, [In, Out] float[] y); - - [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] - internal static extern void d_axpy(int n, double alpha, double[] x, [In, Out] double[] y); - - [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] - internal static extern void c_axpy(int n, ref Complex32 alpha, Complex32[] x, [In, Out] Complex32[] y); - - [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] - internal static extern void z_axpy(int n, ref Complex alpha, Complex[] x, [In, Out] Complex[] y); - - [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] - internal static extern void s_scale(int n, float alpha, [Out] float[] x); - - [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] - internal static extern void d_scale(int n, double alpha, [Out] double[] x); - - [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] - internal static extern void c_scale(int n, ref Complex32 alpha, [In, Out] Complex32[] x); - - [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] - internal static extern void z_scale(int n, ref Complex alpha, [In, Out] Complex[] x); - - [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] - internal static extern float s_dot_product(int n, float[] x, float[] y); - - [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] - internal static extern double d_dot_product(int n, double[] x, double[] y); - - [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] - internal static extern Complex32 c_dot_product(int n, Complex32[] x, Complex32[] y); - - [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] - internal static extern Complex z_dot_product(int n, Complex[] x, Complex[] y); - - [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] - internal static extern void s_matrix_multiply(Transpose transA, Transpose transB, int m, int n, int k, float alpha, float[] x, float[] y, float beta, [In, Out]float[] c); - - [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] - internal static extern void d_matrix_multiply(Transpose transA, Transpose transB, int m, int n, int k, double alpha, double[] x, double[] y, double beta, [In, Out]double[] c); - - [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] - internal static extern void c_matrix_multiply(Transpose transA, Transpose transB, int m, int n, int k, ref Complex32 alpha, Complex32[] x, Complex32[] y, ref Complex32 beta, [In, Out]Complex32[] c); - - [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] - internal static extern void z_matrix_multiply(Transpose transA, Transpose transB, int m, int n, int k, ref Complex alpha, Complex[] x, Complex[] y, ref Complex beta, [In, Out]Complex[] c); - - #endregion BLAS - - #region LAPACK - - [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] - internal static extern void s_cholesky_factor(int n, [In, Out] float[] a); - - [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] - internal static extern void d_cholesky_factor(int n, [In, Out] double[] a); - - [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] - internal static extern void c_cholesky_factor(int n, [In, Out] Complex32[] a); - - [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] - internal static extern void z_cholesky_factor(int n, [In, Out] Complex[] a); - - #endregion LAPACK - - - } -} \ No newline at end of file diff --git a/src/Numerics/Algorithms/LinearAlgebra/Atlas/SafeNativeMethods.tt b/src/Numerics/Algorithms/LinearAlgebra/Atlas/SafeNativeMethods.tt deleted file mode 100644 index 7a0c802b..00000000 --- a/src/Numerics/Algorithms/LinearAlgebra/Atlas/SafeNativeMethods.tt +++ /dev/null @@ -1,9 +0,0 @@ -<#@ template language="C#" debug="true" #> -<#@ output extenstion="cs" #> -<# string namespaceSuffix = "Atlas"; - string library = "ATLAS"; -#> -<#@ include file="..\SafeNativeMethods.include" #> - - } -} \ No newline at end of file diff --git a/src/Numerics/Algorithms/LinearAlgebra/ManagedLinearAlgebraProvider.Complex.cs b/src/Numerics/Algorithms/LinearAlgebra/ManagedLinearAlgebraProvider.Complex.cs index 6ee85a96..7d87b6d5 100644 --- a/src/Numerics/Algorithms/LinearAlgebra/ManagedLinearAlgebraProvider.Complex.cs +++ b/src/Numerics/Algorithms/LinearAlgebra/ManagedLinearAlgebraProvider.Complex.cs @@ -42,7 +42,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The value to scale by. /// The vector to add to . /// This equivalent to the AXPY BLAS routine. - public void AddVectorToScaledVector(Complex[] y, Complex alpha, Complex[] x) + public virtual void AddVectorToScaledVector(Complex[] y, Complex alpha, Complex[] x) { if (y == null) { @@ -80,7 +80,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The scalar. /// The values to scale. /// This is equivalent to the SCAL BLAS routine. - public void ScaleArray(Complex alpha, Complex[] x) + public virtual void ScaleArray(Complex alpha, Complex[] x) { if (x == null) { @@ -102,7 +102,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The vector y. /// The dot product of x and y. /// This is equivalent to the DOT BLAS routine. - public Complex DotProduct(Complex[] x, Complex[] y) + public virtual Complex DotProduct(Complex[] x, Complex[] y) { if (y == null) { @@ -132,7 +132,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// There is no equivalent BLAS routine, but many libraries /// provide optimized (parallel and/or vectorized) versions of this /// routine. - public void AddArrays(Complex[] x, Complex[] y, Complex[] result) + public virtual void AddArrays(Complex[] x, Complex[] y, Complex[] result) { if (y == null) { @@ -167,7 +167,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// There is no equivalent BLAS routine, but many libraries /// provide optimized (parallel and/or vectorized) versions of this /// routine. - public void SubtractArrays(Complex[] x, Complex[] y, Complex[] result) + public virtual void SubtractArrays(Complex[] x, Complex[] y, Complex[] result) { if (y == null) { @@ -202,7 +202,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// There is no equivalent BLAS routine, but many libraries /// provide optimized (parallel and/or vectorized) versions of this /// routine. - public void PointWiseMultiplyArrays(Complex[] x, Complex[] y, Complex[] result) + public virtual void PointWiseMultiplyArrays(Complex[] x, Complex[] y, Complex[] result) { if (y == null) { @@ -237,7 +237,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// There is no equivalent BLAS routine, but many libraries /// provide optimized (parallel and/or vectorized) versions of this /// routine. - public void PointWiseDivideArrays(Complex[] x, Complex[] y, Complex[] result) + public virtual void PointWiseDivideArrays(Complex[] x, Complex[] y, Complex[] result) { if (y == null) { @@ -272,7 +272,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// /// The requested of the matrix. /// - public Complex MatrixNorm(Norm norm, int rows, int columns, Complex[] matrix) + public virtual Complex MatrixNorm(Norm norm, int rows, int columns, Complex[] matrix) { var ret = 0.0; switch (norm) @@ -342,7 +342,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// /// The requested of the matrix. /// - public Complex MatrixNorm(Norm norm, int rows, int columns, Complex[] matrix, Complex[] work) + public virtual Complex MatrixNorm(Norm norm, int rows, int columns, Complex[] matrix, Complex[] work) { return MatrixNorm(norm, rows, columns, matrix); } @@ -359,7 +359,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// Where to store the result of the multiplication. /// This is a simplified version of the BLAS GEMM routine with alpha /// set to 1.0 and beta set to 0.0, and x and y are not transposed. - public void MatrixMultiply(Complex[] x, int rowsX, int columnsX, Complex[] y, int rowsY, int columnsY, Complex[] result) + public virtual void MatrixMultiply(Complex[] x, int rowsX, int columnsX, Complex[] y, int rowsY, int columnsY, Complex[] result) { // First check some basic requirement on the parameters of the matrix multiplication. if (x == null) @@ -441,7 +441,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The number of columns in the matrix. /// The value to scale the matrix. /// The c matrix. - public void MatrixMultiplyWithUpdate(Transpose transposeA, Transpose transposeB, Complex alpha, Complex[] a, int rowsA, int columnsA, Complex[] b, int rowsB, int columnsB, Complex beta, Complex[] c) + public virtual void MatrixMultiplyWithUpdate(Transpose transposeA, Transpose transposeB, Complex alpha, Complex[] a, int rowsA, int columnsA, Complex[] b, int rowsB, int columnsB, Complex beta, Complex[] c) { // Choose nonsensical values for the number of rows in c; fill them in depending // on the operations on a and b. @@ -819,7 +819,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The order of the square matrix . /// On exit, it contains the pivot indices. The size of the array must be . /// This is equivalent to the GETRF LAPACK routine. - public void LUFactor(Complex[] data, int order, int[] ipiv) + public virtual void LUFactor(Complex[] data, int order, int[] ipiv) { if (data == null) { @@ -917,7 +917,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The N by N matrix to invert. Contains the inverse On exit. /// The order of the square matrix . /// This is equivalent to the GETRF and GETRI LAPACK routines. - public void LUInverse(Complex[] a, int order) + public virtual void LUInverse(Complex[] a, int order) { if (a == null) { @@ -941,7 +941,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The order of the square matrix . /// The pivot indices of . /// This is equivalent to the GETRI LAPACK routine. - public void LUInverseFactored(Complex[] a, int order, int[] ipiv) + public virtual void LUInverseFactored(Complex[] a, int order, int[] ipiv) { if (a == null) { @@ -982,7 +982,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal /// work size value. /// This is equivalent to the GETRF and GETRI LAPACK routines. - public void LUInverse(Complex[] a, int order, Complex[] work) + public virtual void LUInverse(Complex[] a, int order, Complex[] work) { LUInverse(a, order); } @@ -997,7 +997,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal /// work size value. /// This is equivalent to the GETRI LAPACK routine. - public void LUInverseFactored(Complex[] a, int order, int[] ipiv, Complex[] work) + public virtual void LUInverseFactored(Complex[] a, int order, int[] ipiv, Complex[] work) { LUInverseFactored(a, order, ipiv); } @@ -1010,7 +1010,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The order of the square matrix . /// The B matrix. /// This is equivalent to the GETRF and GETRS LAPACK routines. - public void LUSolve(int columnsOfB, Complex[] a, int order, Complex[] b) + public virtual void LUSolve(int columnsOfB, Complex[] a, int order, Complex[] b) { if (a == null) { @@ -1046,7 +1046,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The pivot indices of . /// The B matrix. /// This is equivalent to the GETRS LAPACK routine. - public void LUSolveFactored(int columnsOfB, Complex[] a, int order, int[] ipiv, Complex[] b) + public virtual void LUSolveFactored(int columnsOfB, Complex[] a, int order, int[] ipiv, Complex[] b) { if (a == null) { @@ -1142,7 +1142,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The order of the square matrix . /// The B matrix. /// This is equivalent to the GETRF and GETRS LAPACK routines. - public void LUSolve(Transpose transposeA, int columnsOfB, Complex[] a, int order, Complex[] b) + public virtual void LUSolve(Transpose transposeA, int columnsOfB, Complex[] a, int order, Complex[] b) { if (a == null) { @@ -1179,7 +1179,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The pivot indices of . /// The B matrix. /// This is equivalent to the GETRS LAPACK routine. - public void LUSolveFactored(Transpose transposeA, int columnsOfB, Complex[] a, int order, int[] ipiv, Complex[] b) + public virtual void LUSolveFactored(Transpose transposeA, int columnsOfB, Complex[] a, int order, int[] ipiv, Complex[] b) { if (a == null) { @@ -1250,7 +1250,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// the Cholesky factorization. /// The number of rows or columns in the matrix. /// This is equivalent to the POTRF LAPACK routine. - public void CholeskyFactor(Complex[] a, int order) + public virtual void CholeskyFactor(Complex[] a, int order) { if (a == null) { @@ -1338,7 +1338,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The number of rows in the B matrix. /// The number of columns in the B matrix. /// This is equivalent to the POTRF add POTRS LAPACK routines. - public void CholeskySolve(Complex[] a, int orderA, Complex[] b, int rowsB, int columnsB) + public virtual void CholeskySolve(Complex[] a, int orderA, Complex[] b, int rowsB, int columnsB) { if (a == null) { @@ -1373,7 +1373,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The number of rows in the B matrix. /// The number of columns in the B matrix. /// This is equivalent to the POTRS LAPACK routine. - public void CholeskySolveFactored(Complex[] a, int orderA, Complex[] b, int rowsB, int columnsB) + public virtual void CholeskySolveFactored(Complex[] a, int orderA, Complex[] b, int rowsB, int columnsB) { if (a == null) { @@ -1440,7 +1440,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// On exit, A M by M matrix that holds the Q matrix of the /// QR factorization. /// This is similar to the GEQRF and ORGQR LAPACK routines. - public void QRFactor(Complex[] r, int rowsR, int columnsR, Complex[] q) + public virtual void QRFactor(Complex[] r, int rowsR, int columnsR, Complex[] q) { if (r == null) { @@ -1479,7 +1479,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal /// work size value. /// This is similar to the GEQRF and ORGQR LAPACK routines. - public void QRFactor(Complex[] r, int rowsR, int columnsR, Complex[] q, Complex[] work) + public virtual void QRFactor(Complex[] r, int rowsR, int columnsR, Complex[] q, Complex[] work) { if (r == null) { @@ -1643,7 +1643,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The B matrix. /// The number of columns of B. /// On exit, the solution matrix. - public void QRSolve(Complex[] r, int rowsR, int columnsR, Complex[] q, Complex[] b, int columnsB, Complex[] x) + public virtual void QRSolve(Complex[] r, int rowsR, int columnsR, Complex[] q, Complex[] b, int columnsB, Complex[] x) { if (r == null) { @@ -1704,7 +1704,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The work array. The array must have a length of at least N, /// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal /// work size value. - public void QRSolve(Complex[] r, int rowsR, int columnsR, Complex[] q, Complex[] b, int columnsB, Complex[] x, Complex[] work) + public virtual void QRSolve(Complex[] r, int rowsR, int columnsR, Complex[] q, Complex[] b, int columnsB, Complex[] x, Complex[] work) { if (r == null) { @@ -1768,7 +1768,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The B matrix. /// The number of columns of B. /// On exit, the solution matrix. - public void QRSolveFactored(Complex[] q, Complex[] r, int rowsR, int columnsR, Complex[] b, int columnsB, Complex[] x) + public virtual void QRSolveFactored(Complex[] q, Complex[] r, int rowsR, int columnsR, Complex[] b, int columnsB, Complex[] x) { if (r == null) { @@ -1876,7 +1876,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// If is true, on exit VT contains the transposed /// right singular vectors. /// This is equivalent to the GESVD LAPACK routine. - public void SingularValueDecomposition(bool computeVectors, Complex[] a, int rowsA, int columnsA, Complex[] s, Complex[] u, Complex[] vt) + public virtual void SingularValueDecomposition(bool computeVectors, Complex[] a, int rowsA, int columnsA, Complex[] s, Complex[] u, Complex[] vt) { if (a == null) { @@ -1934,7 +1934,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// Max(3*Min(M, N) + Max(M, N), 5*Min(M,N)). For complex matrices, 2*Min(M, N) + Max(M, N). /// On exit, work[0] contains the optimal work size value. /// This is equivalent to the GESVD LAPACK routine. - public void SingularValueDecomposition(bool computeVectors, Complex[] a, int rowsA, int columnsA, Complex[] s, Complex[] u, Complex[] vt, Complex[] work) + public virtual void SingularValueDecomposition(bool computeVectors, Complex[] a, int rowsA, int columnsA, Complex[] s, Complex[] u, Complex[] vt, Complex[] work) { if (a == null) { @@ -2616,7 +2616,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The B matrix. /// The number of columns of B. /// On exit, the solution matrix. - public void SvdSolve(Complex[] a, int rowsA, int columnsA, Complex[] s, Complex[] u, Complex[] vt, Complex[] b, int columnsB, Complex[] x) + public virtual void SvdSolve(Complex[] a, int rowsA, int columnsA, Complex[] s, Complex[] u, Complex[] vt, Complex[] b, int columnsB, Complex[] x) { if (a == null) { @@ -2693,7 +2693,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The work array. For real matrices, the work array should be at least /// Max(3*Min(M, N) + Max(M, N), 5*Min(M,N)). For complex matrices, 2*Min(M, N) + Max(M, N). /// On exit, work[0] contains the optimal work size value. - public void SvdSolve(Complex[] a, int rowsA, int columnsA, Complex[] s, Complex[] u, Complex[] vt, Complex[] b, int columnsB, Complex[] x, Complex[] work) + public virtual void SvdSolve(Complex[] a, int rowsA, int columnsA, Complex[] s, Complex[] u, Complex[] vt, Complex[] b, int columnsB, Complex[] x, Complex[] work) { if (a == null) { @@ -2776,7 +2776,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The B matrix. /// The number of columns of B. /// On exit, the solution matrix. - public void SvdSolveFactored(int rowsA, int columnsA, Complex[] s, Complex[] u, Complex[] vt, Complex[] b, int columnsB, Complex[] x) + public virtual void SvdSolveFactored(int rowsA, int columnsA, Complex[] s, Complex[] u, Complex[] vt, Complex[] b, int columnsB, Complex[] x) { if (s == null) { diff --git a/src/Numerics/Algorithms/LinearAlgebra/ManagedLinearAlgebraProvider.Complex32.cs b/src/Numerics/Algorithms/LinearAlgebra/ManagedLinearAlgebraProvider.Complex32.cs index d26a4b04..b00cc42a 100644 --- a/src/Numerics/Algorithms/LinearAlgebra/ManagedLinearAlgebraProvider.Complex32.cs +++ b/src/Numerics/Algorithms/LinearAlgebra/ManagedLinearAlgebraProvider.Complex32.cs @@ -42,7 +42,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The value to scale by. /// The vector to add to . /// This equivalent to the AXPY BLAS routine. - public void AddVectorToScaledVector(Complex32[] y, Complex32 alpha, Complex32[] x) + public virtual void AddVectorToScaledVector(Complex32[] y, Complex32 alpha, Complex32[] x) { if (y == null) { @@ -80,7 +80,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The scalar. /// The values to scale. /// This is equivalent to the SCAL BLAS routine. - public void ScaleArray(Complex32 alpha, Complex32[] x) + public virtual void ScaleArray(Complex32 alpha, Complex32[] x) { if (x == null) { @@ -102,7 +102,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The vector y. /// The dot product of x and y. /// This is equivalent to the DOT BLAS routine. - public Complex32 DotProduct(Complex32[] x, Complex32[] y) + public virtual Complex32 DotProduct(Complex32[] x, Complex32[] y) { if (y == null) { @@ -139,7 +139,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// There is no equivalent BLAS routine, but many libraries /// provide optimized (parallel and/or vectorized) versions of this /// routine. - public void AddArrays(Complex32[] x, Complex32[] y, Complex32[] result) + public virtual void AddArrays(Complex32[] x, Complex32[] y, Complex32[] result) { if (y == null) { @@ -174,7 +174,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// There is no equivalent BLAS routine, but many libraries /// provide optimized (parallel and/or vectorized) versions of this /// routine. - public void SubtractArrays(Complex32[] x, Complex32[] y, Complex32[] result) + public virtual void SubtractArrays(Complex32[] x, Complex32[] y, Complex32[] result) { if (y == null) { @@ -209,7 +209,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// There is no equivalent BLAS routine, but many libraries /// provide optimized (parallel and/or vectorized) versions of this /// routine. - public void PointWiseMultiplyArrays(Complex32[] x, Complex32[] y, Complex32[] result) + public virtual void PointWiseMultiplyArrays(Complex32[] x, Complex32[] y, Complex32[] result) { if (y == null) { @@ -244,7 +244,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// There is no equivalent BLAS routine, but many libraries /// provide optimized (parallel and/or vectorized) versions of this /// routine. - public void PointWiseDivideArrays(Complex32[] x, Complex32[] y, Complex32[] result) + public virtual void PointWiseDivideArrays(Complex32[] x, Complex32[] y, Complex32[] result) { if (y == null) { @@ -279,7 +279,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// /// The requested of the matrix. /// - public Complex32 MatrixNorm(Norm norm, int rows, int columns, Complex32[] matrix) + public virtual Complex32 MatrixNorm(Norm norm, int rows, int columns, Complex32[] matrix) { var ret = 0.0; switch (norm) @@ -349,7 +349,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// /// The requested of the matrix. /// - public Complex32 MatrixNorm(Norm norm, int rows, int columns, Complex32[] matrix, Complex32[] work) + public virtual Complex32 MatrixNorm(Norm norm, int rows, int columns, Complex32[] matrix, Complex32[] work) { return MatrixNorm(norm, rows, columns, matrix); } @@ -366,7 +366,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// Where to store the result of the multiplication. /// This is a simplified version of the BLAS GEMM routine with alpha /// set to 1.0 and beta set to 0.0, and x and y are not transposed. - public void MatrixMultiply(Complex32[] x, int rowsX, int columnsX, Complex32[] y, int rowsY, int columnsY, Complex32[] result) + public virtual void MatrixMultiply(Complex32[] x, int rowsX, int columnsX, Complex32[] y, int rowsY, int columnsY, Complex32[] result) { // First check some basic requirement on the parameters of the matrix multiplication. if (x == null) @@ -448,7 +448,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The number of columns in the matrix. /// The value to scale the matrix. /// The c matrix. - public void MatrixMultiplyWithUpdate(Transpose transposeA, Transpose transposeB, Complex32 alpha, Complex32[] a, int rowsA, int columnsA, Complex32[] b, int rowsB, int columnsB, Complex32 beta, Complex32[] c) + public virtual void MatrixMultiplyWithUpdate(Transpose transposeA, Transpose transposeB, Complex32 alpha, Complex32[] a, int rowsA, int columnsA, Complex32[] b, int rowsB, int columnsB, Complex32 beta, Complex32[] c) { // Choose nonsensical values for the number of rows in c; fill them in depending // on the operations on a and b. @@ -826,7 +826,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The order of the square matrix . /// On exit, it contains the pivot indices. The size of the array must be . /// This is equivalent to the GETRF LAPACK routine. - public void LUFactor(Complex32[] data, int order, int[] ipiv) + public virtual void LUFactor(Complex32[] data, int order, int[] ipiv) { if (data == null) { @@ -924,7 +924,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The N by N matrix to invert. Contains the inverse On exit. /// The order of the square matrix . /// This is equivalent to the GETRF and GETRI LAPACK routines. - public void LUInverse(Complex32[] a, int order) + public virtual void LUInverse(Complex32[] a, int order) { if (a == null) { @@ -948,7 +948,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The order of the square matrix . /// The pivot indices of . /// This is equivalent to the GETRI LAPACK routine. - public void LUInverseFactored(Complex32[] a, int order, int[] ipiv) + public virtual void LUInverseFactored(Complex32[] a, int order, int[] ipiv) { if (a == null) { @@ -989,7 +989,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal /// work size value. /// This is equivalent to the GETRF and GETRI LAPACK routines. - public void LUInverse(Complex32[] a, int order, Complex32[] work) + public virtual void LUInverse(Complex32[] a, int order, Complex32[] work) { LUInverse(a, order); } @@ -1004,7 +1004,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal /// work size value. /// This is equivalent to the GETRI LAPACK routine. - public void LUInverseFactored(Complex32[] a, int order, int[] ipiv, Complex32[] work) + public virtual void LUInverseFactored(Complex32[] a, int order, int[] ipiv, Complex32[] work) { LUInverseFactored(a, order, ipiv); } @@ -1017,7 +1017,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The order of the square matrix . /// The B matrix. /// This is equivalent to the GETRF and GETRS LAPACK routines. - public void LUSolve(int columnsOfB, Complex32[] a, int order, Complex32[] b) + public virtual void LUSolve(int columnsOfB, Complex32[] a, int order, Complex32[] b) { if (a == null) { @@ -1053,7 +1053,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The pivot indices of . /// The B matrix. /// This is equivalent to the GETRS LAPACK routine. - public void LUSolveFactored(int columnsOfB, Complex32[] a, int order, int[] ipiv, Complex32[] b) + public virtual void LUSolveFactored(int columnsOfB, Complex32[] a, int order, int[] ipiv, Complex32[] b) { if (a == null) { @@ -1149,7 +1149,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The order of the square matrix . /// The B matrix. /// This is equivalent to the GETRF and GETRS LAPACK routines. - public void LUSolve(Transpose transposeA, int columnsOfB, Complex32[] a, int order, Complex32[] b) + public virtual void LUSolve(Transpose transposeA, int columnsOfB, Complex32[] a, int order, Complex32[] b) { if (a == null) { @@ -1186,7 +1186,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The pivot indices of . /// The B matrix. /// This is equivalent to the GETRS LAPACK routine. - public void LUSolveFactored(Transpose transposeA, int columnsOfB, Complex32[] a, int order, int[] ipiv, Complex32[] b) + public virtual void LUSolveFactored(Transpose transposeA, int columnsOfB, Complex32[] a, int order, int[] ipiv, Complex32[] b) { if (a == null) { @@ -1257,7 +1257,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// the Cholesky factorization. /// The number of rows or columns in the matrix. /// This is equivalent to the POTRF LAPACK routine. - public void CholeskyFactor(Complex32[] a, int order) + public virtual void CholeskyFactor(Complex32[] a, int order) { if (a == null) { @@ -1345,7 +1345,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The number of rows in the B matrix. /// The number of columns in the B matrix. /// This is equivalent to the POTRF add POTRS LAPACK routines. - public void CholeskySolve(Complex32[] a, int orderA, Complex32[] b, int rowsB, int columnsB) + public virtual void CholeskySolve(Complex32[] a, int orderA, Complex32[] b, int rowsB, int columnsB) { if (a == null) { @@ -1380,7 +1380,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The number of rows in the B matrix. /// The number of columns in the B matrix. /// This is equivalent to the POTRS LAPACK routine. - public void CholeskySolveFactored(Complex32[] a, int orderA, Complex32[] b, int rowsB, int columnsB) + public virtual void CholeskySolveFactored(Complex32[] a, int orderA, Complex32[] b, int rowsB, int columnsB) { if (a == null) { @@ -1447,7 +1447,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// On exit, A M by M matrix that holds the Q matrix of the /// QR factorization. /// This is similar to the GEQRF and ORGQR LAPACK routines. - public void QRFactor(Complex32[] r, int rowsR, int columnsR, Complex32[] q) + public virtual void QRFactor(Complex32[] r, int rowsR, int columnsR, Complex32[] q) { if (r == null) { @@ -1486,7 +1486,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal /// work size value. /// This is similar to the GEQRF and ORGQR LAPACK routines. - public void QRFactor(Complex32[] r, int rowsR, int columnsR, Complex32[] q, Complex32[] work) + public virtual void QRFactor(Complex32[] r, int rowsR, int columnsR, Complex32[] q, Complex32[] work) { if (r == null) { @@ -1650,7 +1650,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The B matrix. /// The number of columns of B. /// On exit, the solution matrix. - public void QRSolve(Complex32[] r, int rowsR, int columnsR, Complex32[] q, Complex32[] b, int columnsB, Complex32[] x) + public virtual void QRSolve(Complex32[] r, int rowsR, int columnsR, Complex32[] q, Complex32[] b, int columnsB, Complex32[] x) { if (r == null) { @@ -1711,7 +1711,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The work array. The array must have a length of at least N, /// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal /// work size value. - public void QRSolve(Complex32[] r, int rowsR, int columnsR, Complex32[] q, Complex32[] b, int columnsB, Complex32[] x, Complex32[] work) + public virtual void QRSolve(Complex32[] r, int rowsR, int columnsR, Complex32[] q, Complex32[] b, int columnsB, Complex32[] x, Complex32[] work) { if (r == null) { @@ -1775,7 +1775,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The B matrix. /// The number of columns of B. /// On exit, the solution matrix. - public void QRSolveFactored(Complex32[] q, Complex32[] r, int rowsR, int columnsR, Complex32[] b, int columnsB, Complex32[] x) + public virtual void QRSolveFactored(Complex32[] q, Complex32[] r, int rowsR, int columnsR, Complex32[] b, int columnsB, Complex32[] x) { if (r == null) { @@ -1883,7 +1883,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// If is true, on exit VT contains the transposed /// right singular vectors. /// This is equivalent to the GESVD LAPACK routine. - public void SingularValueDecomposition(bool computeVectors, Complex32[] a, int rowsA, int columnsA, Complex32[] s, Complex32[] u, Complex32[] vt) + public virtual void SingularValueDecomposition(bool computeVectors, Complex32[] a, int rowsA, int columnsA, Complex32[] s, Complex32[] u, Complex32[] vt) { if (a == null) { @@ -1941,7 +1941,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// Max(3*Min(M, N) + Max(M, N), 5*Min(M,N)). For complex matrices, 2*Min(M, N) + Max(M, N). /// On exit, work[0] contains the optimal work size value. /// This is equivalent to the GESVD LAPACK routine. - public void SingularValueDecomposition(bool computeVectors, Complex32[] a, int rowsA, int columnsA, Complex32[] s, Complex32[] u, Complex32[] vt, Complex32[] work) + public virtual void SingularValueDecomposition(bool computeVectors, Complex32[] a, int rowsA, int columnsA, Complex32[] s, Complex32[] u, Complex32[] vt, Complex32[] work) { if (a == null) { @@ -2623,7 +2623,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The B matrix. /// The number of columns of B. /// On exit, the solution matrix. - public void SvdSolve(Complex32[] a, int rowsA, int columnsA, Complex32[] s, Complex32[] u, Complex32[] vt, Complex32[] b, int columnsB, Complex32[] x) + public virtual void SvdSolve(Complex32[] a, int rowsA, int columnsA, Complex32[] s, Complex32[] u, Complex32[] vt, Complex32[] b, int columnsB, Complex32[] x) { if (a == null) { @@ -2700,7 +2700,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The work array. For real matrices, the work array should be at least /// Max(3*Min(M, N) + Max(M, N), 5*Min(M,N)). For complex matrices, 2*Min(M, N) + Max(M, N). /// On exit, work[0] contains the optimal work size value. - public void SvdSolve(Complex32[] a, int rowsA, int columnsA, Complex32[] s, Complex32[] u, Complex32[] vt, Complex32[] b, int columnsB, Complex32[] x, Complex32[] work) + public virtual void SvdSolve(Complex32[] a, int rowsA, int columnsA, Complex32[] s, Complex32[] u, Complex32[] vt, Complex32[] b, int columnsB, Complex32[] x, Complex32[] work) { if (a == null) { @@ -2783,7 +2783,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The B matrix. /// The number of columns of B. /// On exit, the solution matrix. - public void SvdSolveFactored(int rowsA, int columnsA, Complex32[] s, Complex32[] u, Complex32[] vt, Complex32[] b, int columnsB, Complex32[] x) + public virtual void SvdSolveFactored(int rowsA, int columnsA, Complex32[] s, Complex32[] u, Complex32[] vt, Complex32[] b, int columnsB, Complex32[] x) { if (s == null) { diff --git a/src/Numerics/Algorithms/LinearAlgebra/ManagedLinearAlgebraProvider.Double.cs b/src/Numerics/Algorithms/LinearAlgebra/ManagedLinearAlgebraProvider.Double.cs index 35339af6..6b9c8d8b 100644 --- a/src/Numerics/Algorithms/LinearAlgebra/ManagedLinearAlgebraProvider.Double.cs +++ b/src/Numerics/Algorithms/LinearAlgebra/ManagedLinearAlgebraProvider.Double.cs @@ -41,7 +41,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The value to scale by. /// The vector to add to . /// This equivalent to the AXPY BLAS routine. - public void AddVectorToScaledVector(double[] y, double alpha, double[] x) + public virtual void AddVectorToScaledVector(double[] y, double alpha, double[] x) { if (y == null) { @@ -79,7 +79,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The scalar. /// The values to scale. /// This is equivalent to the SCAL BLAS routine. - public void ScaleArray(double alpha, double[] x) + public virtual void ScaleArray(double alpha, double[] x) { if (x == null) { @@ -101,7 +101,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The vector y. /// The dot product of x and y. /// This is equivalent to the DOT BLAS routine. - public double DotProduct(double[] x, double[] y) + public virtual double DotProduct(double[] x, double[] y) { if (y == null) { @@ -131,7 +131,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// There is no equivalent BLAS routine, but many libraries /// provide optimized (parallel and/or vectorized) versions of this /// routine. - public void AddArrays(double[] x, double[] y, double[] result) + public virtual void AddArrays(double[] x, double[] y, double[] result) { if (y == null) { @@ -166,7 +166,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// There is no equivalent BLAS routine, but many libraries /// provide optimized (parallel and/or vectorized) versions of this /// routine. - public void SubtractArrays(double[] x, double[] y, double[] result) + public virtual void SubtractArrays(double[] x, double[] y, double[] result) { if (y == null) { @@ -201,7 +201,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// There is no equivalent BLAS routine, but many libraries /// provide optimized (parallel and/or vectorized) versions of this /// routine. - public void PointWiseMultiplyArrays(double[] x, double[] y, double[] result) + public virtual void PointWiseMultiplyArrays(double[] x, double[] y, double[] result) { if (y == null) { @@ -236,7 +236,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// There is no equivalent BLAS routine, but many libraries /// provide optimized (parallel and/or vectorized) versions of this /// routine. - public void PointWiseDivideArrays(double[] x, double[] y, double[] result) + public virtual void PointWiseDivideArrays(double[] x, double[] y, double[] result) { if (y == null) { @@ -271,7 +271,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// /// The requested of the matrix. /// - public double MatrixNorm(Norm norm, int rows, int columns, double[] matrix) + public virtual double MatrixNorm(Norm norm, int rows, int columns, double[] matrix) { var ret = 0.0; switch (norm) @@ -340,7 +340,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// /// The requested of the matrix. /// - public double MatrixNorm(Norm norm, int rows, int columns, double[] matrix, double[] work) + public virtual double MatrixNorm(Norm norm, int rows, int columns, double[] matrix, double[] work) { return MatrixNorm(norm, rows, columns, matrix); } @@ -357,7 +357,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// Where to store the result of the multiplication. /// This is a simplified version of the BLAS GEMM routine with alpha /// set to 1.0 and beta set to 0.0, and x and y are not transposed. - public void MatrixMultiply(double[] x, int rowsX, int columnsX, double[] y, int rowsY, int columnsY, double[] result) + public virtual void MatrixMultiply(double[] x, int rowsX, int columnsX, double[] y, int rowsY, int columnsY, double[] result) { // First check some basic requirement on the parameters of the matrix multiplication. if (x == null) @@ -439,7 +439,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The number of columns in the matrix. /// The value to scale the matrix. /// The c matrix. - public void MatrixMultiplyWithUpdate(Transpose transposeA, Transpose transposeB, double alpha, double[] a, int rowsA, int columnsA, double[] b, int rowsB, int columnsB, double beta, double[] c) + public virtual void MatrixMultiplyWithUpdate(Transpose transposeA, Transpose transposeB, double alpha, double[] a, int rowsA, int columnsA, double[] b, int rowsB, int columnsB, double beta, double[] c) { // Choose nonsensical values for the number of rows in c; fill them in depending // on the operations on a and b. @@ -817,7 +817,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The order of the square matrix . /// On exit, it contains the pivot indices. The size of the array must be . /// This is equivalent to the GETRF LAPACK routine. - public void LUFactor(double[] data, int order, int[] ipiv) + public virtual void LUFactor(double[] data, int order, int[] ipiv) { if (data == null) { @@ -915,7 +915,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The N by N matrix to invert. Contains the inverse On exit. /// The order of the square matrix . /// This is equivalent to the GETRF and GETRI LAPACK routines. - public void LUInverse(double[] a, int order) + public virtual void LUInverse(double[] a, int order) { if (a == null) { @@ -939,7 +939,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The order of the square matrix . /// The pivot indices of . /// This is equivalent to the GETRI LAPACK routine. - public void LUInverseFactored(double[] a, int order, int[] ipiv) + public virtual void LUInverseFactored(double[] a, int order, int[] ipiv) { if (a == null) { @@ -980,7 +980,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal /// work size value. /// This is equivalent to the GETRF and GETRI LAPACK routines. - public void LUInverse(double[] a, int order, double[] work) + public virtual void LUInverse(double[] a, int order, double[] work) { LUInverse(a, order); } @@ -995,7 +995,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal /// work size value. /// This is equivalent to the GETRI LAPACK routine. - public void LUInverseFactored(double[] a, int order, int[] ipiv, double[] work) + public virtual void LUInverseFactored(double[] a, int order, int[] ipiv, double[] work) { LUInverseFactored(a, order, ipiv); } @@ -1008,7 +1008,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The order of the square matrix . /// The B matrix. /// This is equivalent to the GETRF and GETRS LAPACK routines. - public void LUSolve(int columnsOfB, double[] a, int order, double[] b) + public virtual void LUSolve(int columnsOfB, double[] a, int order, double[] b) { if (a == null) { @@ -1044,7 +1044,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The pivot indices of . /// The B matrix. /// This is equivalent to the GETRS LAPACK routine. - public void LUSolveFactored(int columnsOfB, double[] a, int order, int[] ipiv, double[] b) + public virtual void LUSolveFactored(int columnsOfB, double[] a, int order, int[] ipiv, double[] b) { if (a == null) { @@ -1140,7 +1140,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The order of the square matrix . /// The B matrix. /// This is equivalent to the GETRF and GETRS LAPACK routines. - public void LUSolve(Transpose transposeA, int columnsOfB, double[] a, int order, double[] b) + public virtual void LUSolve(Transpose transposeA, int columnsOfB, double[] a, int order, double[] b) { if (a == null) { @@ -1177,7 +1177,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The pivot indices of . /// The B matrix. /// This is equivalent to the GETRS LAPACK routine. - public void LUSolveFactored(Transpose transposeA, int columnsOfB, double[] a, int order, int[] ipiv, double[] b) + public virtual void LUSolveFactored(Transpose transposeA, int columnsOfB, double[] a, int order, int[] ipiv, double[] b) { if (a == null) { @@ -1235,7 +1235,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// the Cholesky factorization. /// The number of rows or columns in the matrix. /// This is equivalent to the POTRF LAPACK routine. - public void CholeskyFactor(double[] a, int order) + public virtual void CholeskyFactor(double[] a, int order) { if (a == null) { @@ -1323,7 +1323,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The number of rows in the B matrix. /// The number of columns in the B matrix. /// This is equivalent to the POTRF add POTRS LAPACK routines. - public void CholeskySolve(double[] a, int orderA, double[] b, int rowsB, int columnsB) + public virtual void CholeskySolve(double[] a, int orderA, double[] b, int rowsB, int columnsB) { if (a == null) { @@ -1358,7 +1358,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The number of rows in the B matrix. /// The number of columns in the B matrix. /// This is equivalent to the POTRS LAPACK routine. - public void CholeskySolveFactored(double[] a, int orderA, double[] b, int rowsB, int columnsB) + public virtual void CholeskySolveFactored(double[] a, int orderA, double[] b, int rowsB, int columnsB) { if (a == null) { @@ -1425,7 +1425,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// On exit, A M by M matrix that holds the Q matrix of the /// QR factorization. /// This is similar to the GEQRF and ORGQR LAPACK routines. - public void QRFactor(double[] r, int rowsR, int columnsR, double[] q) + public virtual void QRFactor(double[] r, int rowsR, int columnsR, double[] q) { if (r == null) { @@ -1464,7 +1464,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal /// work size value. /// This is similar to the GEQRF and ORGQR LAPACK routines. - public void QRFactor(double[] r, int rowsR, int columnsR, double[] q, double[] work) + public virtual void QRFactor(double[] r, int rowsR, int columnsR, double[] q, double[] work) { if (r == null) { @@ -1629,7 +1629,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The B matrix. /// The number of columns of B. /// On exit, the solution matrix. - public void QRSolve(double[] r, int rowsR, int columnsR, double[] q, double[] b, int columnsB, double[] x) + public virtual void QRSolve(double[] r, int rowsR, int columnsR, double[] q, double[] b, int columnsB, double[] x) { if (r == null) { @@ -1690,7 +1690,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The work array. The array must have a length of at least N, /// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal /// work size value. - public void QRSolve(double[] r, int rowsR, int columnsR, double[] q, double[] b, int columnsB, double[] x, double[] work) + public virtual void QRSolve(double[] r, int rowsR, int columnsR, double[] q, double[] b, int columnsB, double[] x, double[] work) { if (r == null) { @@ -1754,7 +1754,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The B matrix. /// The number of columns of B. /// On exit, the solution matrix. - public void QRSolveFactored(double[] q, double[] r, int rowsR, int columnsR, double[] b, int columnsB, double[] x) + public virtual void QRSolveFactored(double[] q, double[] r, int rowsR, int columnsR, double[] b, int columnsB, double[] x) { if (r == null) { @@ -1862,7 +1862,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// If is true, on exit VT contains the transposed /// right singular vectors. /// This is equivalent to the GESVD LAPACK routine. - public void SingularValueDecomposition(bool computeVectors, double[] a, int rowsA, int columnsA, double[] s, double[] u, double[] vt) + public virtual void SingularValueDecomposition(bool computeVectors, double[] a, int rowsA, int columnsA, double[] s, double[] u, double[] vt) { if (a == null) { @@ -1920,7 +1920,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// Max(3*Min(M, N) + Max(M, N), 5*Min(M,N)). For complex matrices, 2*Min(M, N) + Max(M, N). /// On exit, work[0] contains the optimal work size value. /// This is equivalent to the GESVD LAPACK routine. - public void SingularValueDecomposition(bool computeVectors, double[] a, int rowsA, int columnsA, double[] s, double[] u, double[] vt, double[] work) + public virtual void SingularValueDecomposition(bool computeVectors, double[] a, int rowsA, int columnsA, double[] s, double[] u, double[] vt, double[] work) { if (a == null) { @@ -2658,7 +2658,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The B matrix. /// The number of columns of B. /// On exit, the solution matrix. - public void SvdSolve(double[] a, int rowsA, int columnsA, double[] s, double[] u, double[] vt, double[] b, int columnsB, double[] x) + public virtual void SvdSolve(double[] a, int rowsA, int columnsA, double[] s, double[] u, double[] vt, double[] b, int columnsB, double[] x) { if (a == null) { @@ -2735,7 +2735,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The work array. For real matrices, the work array should be at least /// Max(3*Min(M, N) + Max(M, N), 5*Min(M,N)). For complex matrices, 2*Min(M, N) + Max(M, N). /// On exit, work[0] contains the optimal work size value. - public void SvdSolve(double[] a, int rowsA, int columnsA, double[] s, double[] u, double[] vt, double[] b, int columnsB, double[] x, double[] work) + public virtual void SvdSolve(double[] a, int rowsA, int columnsA, double[] s, double[] u, double[] vt, double[] b, int columnsB, double[] x, double[] work) { if (a == null) { @@ -2818,7 +2818,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The B matrix. /// The number of columns of B. /// On exit, the solution matrix. - public void SvdSolveFactored(int rowsA, int columnsA, double[] s, double[] u, double[] vt, double[] b, int columnsB, double[] x) + public virtual void SvdSolveFactored(int rowsA, int columnsA, double[] s, double[] u, double[] vt, double[] b, int columnsB, double[] x) { if (s == null) { diff --git a/src/Numerics/Algorithms/LinearAlgebra/ManagedLinearAlgebraProvider.Single.cs b/src/Numerics/Algorithms/LinearAlgebra/ManagedLinearAlgebraProvider.Single.cs index fde7d228..df5ba92f 100644 --- a/src/Numerics/Algorithms/LinearAlgebra/ManagedLinearAlgebraProvider.Single.cs +++ b/src/Numerics/Algorithms/LinearAlgebra/ManagedLinearAlgebraProvider.Single.cs @@ -42,7 +42,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The value to scale by. /// The vector to add to . /// This equivalent to the AXPY BLAS routine. - public void AddVectorToScaledVector(float[] y, float alpha, float[] x) + public virtual void AddVectorToScaledVector(float[] y, float alpha, float[] x) { if (y == null) { @@ -80,7 +80,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The scalar. /// The values to scale. /// This is equivalent to the SCAL BLAS routine. - public void ScaleArray(float alpha, float[] x) + public virtual void ScaleArray(float alpha, float[] x) { if (x == null) { @@ -102,7 +102,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The vector y. /// The dot product of x and y. /// This is equivalent to the DOT BLAS routine. - public float DotProduct(float[] x, float[] y) + public virtual float DotProduct(float[] x, float[] y) { if (y == null) { @@ -134,7 +134,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// There is no equivalent BLAS routine, but many libraries /// provide optimized (parallel and/or vectorized) versions of this /// routine. - public void AddArrays(float[] x, float[] y, float[] result) + public virtual void AddArrays(float[] x, float[] y, float[] result) { if (y == null) { @@ -169,7 +169,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// There is no equivalent BLAS routine, but many libraries /// provide optimized (parallel and/or vectorized) versions of this /// routine. - public void SubtractArrays(float[] x, float[] y, float[] result) + public virtual void SubtractArrays(float[] x, float[] y, float[] result) { if (y == null) { @@ -204,7 +204,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// There is no equivalent BLAS routine, but many libraries /// provide optimized (parallel and/or vectorized) versions of this /// routine. - public void PointWiseMultiplyArrays(float[] x, float[] y, float[] result) + public virtual void PointWiseMultiplyArrays(float[] x, float[] y, float[] result) { if (y == null) { @@ -239,7 +239,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// There is no equivalent BLAS routine, but many libraries /// provide optimized (parallel and/or vectorized) versions of this /// routine. - public void PointWiseDivideArrays(float[] x, float[] y, float[] result) + public virtual void PointWiseDivideArrays(float[] x, float[] y, float[] result) { if (y == null) { @@ -274,7 +274,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// /// The requested of the matrix. /// - public float MatrixNorm(Norm norm, int rows, int columns, float[] matrix) + public virtual float MatrixNorm(Norm norm, int rows, int columns, float[] matrix) { var ret = 0.0; switch (norm) @@ -344,7 +344,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// /// The requested of the matrix. /// - public float MatrixNorm(Norm norm, int rows, int columns, float[] matrix, float[] work) + public virtual float MatrixNorm(Norm norm, int rows, int columns, float[] matrix, float[] work) { return MatrixNorm(norm, rows, columns, matrix); } @@ -361,7 +361,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// Where to store the result of the multiplication. /// This is a simplified version of the BLAS GEMM routine with alpha /// set to 1.0 and beta set to 0.0, and x and y are not transposed. - public void MatrixMultiply(float[] x, int rowsX, int columnsX, float[] y, int rowsY, int columnsY, float[] result) + public virtual void MatrixMultiply(float[] x, int rowsX, int columnsX, float[] y, int rowsY, int columnsY, float[] result) { // First check some basic requirement on the parameters of the matrix multiplication. if (x == null) @@ -443,7 +443,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The number of columns in the matrix. /// The value to scale the matrix. /// The c matrix. - public void MatrixMultiplyWithUpdate(Transpose transposeA, Transpose transposeB, float alpha, float[] a, int rowsA, int columnsA, float[] b, int rowsB, int columnsB, float beta, float[] c) + public virtual void MatrixMultiplyWithUpdate(Transpose transposeA, Transpose transposeB, float alpha, float[] a, int rowsA, int columnsA, float[] b, int rowsB, int columnsB, float beta, float[] c) { // Choose nonsensical values for the number of rows in c; fill them in depending // on the operations on a and b. @@ -821,7 +821,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The order of the square matrix . /// On exit, it contains the pivot indices. The size of the array must be . /// This is equivalent to the GETRF LAPACK routine. - public void LUFactor(float[] data, int order, int[] ipiv) + public virtual void LUFactor(float[] data, int order, int[] ipiv) { if (data == null) { @@ -919,7 +919,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The N by N matrix to invert. Contains the inverse On exit. /// The order of the square matrix . /// This is equivalent to the GETRF and GETRI LAPACK routines. - public void LUInverse(float[] a, int order) + public virtual void LUInverse(float[] a, int order) { if (a == null) { @@ -943,7 +943,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The order of the square matrix . /// The pivot indices of . /// This is equivalent to the GETRI LAPACK routine. - public void LUInverseFactored(float[] a, int order, int[] ipiv) + public virtual void LUInverseFactored(float[] a, int order, int[] ipiv) { if (a == null) { @@ -984,7 +984,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal /// work size value. /// This is equivalent to the GETRF and GETRI LAPACK routines. - public void LUInverse(float[] a, int order, float[] work) + public virtual void LUInverse(float[] a, int order, float[] work) { LUInverse(a, order); } @@ -999,7 +999,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal /// work size value. /// This is equivalent to the GETRI LAPACK routine. - public void LUInverseFactored(float[] a, int order, int[] ipiv, float[] work) + public virtual void LUInverseFactored(float[] a, int order, int[] ipiv, float[] work) { LUInverseFactored(a, order, ipiv); } @@ -1012,7 +1012,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The order of the square matrix . /// The B matrix. /// This is equivalent to the GETRF and GETRS LAPACK routines. - public void LUSolve(int columnsOfB, float[] a, int order, float[] b) + public virtual void LUSolve(int columnsOfB, float[] a, int order, float[] b) { if (a == null) { @@ -1048,7 +1048,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The pivot indices of . /// The B matrix. /// This is equivalent to the GETRS LAPACK routine. - public void LUSolveFactored(int columnsOfB, float[] a, int order, int[] ipiv, float[] b) + public virtual void LUSolveFactored(int columnsOfB, float[] a, int order, int[] ipiv, float[] b) { if (a == null) { @@ -1144,7 +1144,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The order of the square matrix . /// The B matrix. /// This is equivalent to the GETRF and GETRS LAPACK routines. - public void LUSolve(Transpose transposeA, int columnsOfB, float[] a, int order, float[] b) + public virtual void LUSolve(Transpose transposeA, int columnsOfB, float[] a, int order, float[] b) { if (a == null) { @@ -1181,7 +1181,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The pivot indices of . /// The B matrix. /// This is equivalent to the GETRS LAPACK routine. - public void LUSolveFactored(Transpose transposeA, int columnsOfB, float[] a, int order, int[] ipiv, float[] b) + public virtual void LUSolveFactored(Transpose transposeA, int columnsOfB, float[] a, int order, int[] ipiv, float[] b) { if (a == null) { @@ -1239,7 +1239,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// the Cholesky factorization. /// The number of rows or columns in the matrix. /// This is equivalent to the POTRF LAPACK routine. - public void CholeskyFactor(float[] a, int order) + public virtual void CholeskyFactor(float[] a, int order) { if (a == null) { @@ -1327,7 +1327,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The number of rows in the B matrix. /// The number of columns in the B matrix. /// This is equivalent to the POTRF add POTRS LAPACK routines. - public void CholeskySolve(float[] a, int orderA, float[] b, int rowsB, int columnsB) + public virtual void CholeskySolve(float[] a, int orderA, float[] b, int rowsB, int columnsB) { if (a == null) { @@ -1362,7 +1362,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The number of rows in the B matrix. /// The number of columns in the B matrix. /// This is equivalent to the POTRS LAPACK routine. - public void CholeskySolveFactored(float[] a, int orderA, float[] b, int rowsB, int columnsB) + public virtual void CholeskySolveFactored(float[] a, int orderA, float[] b, int rowsB, int columnsB) { if (a == null) { @@ -1429,7 +1429,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// On exit, A M by M matrix that holds the Q matrix of the /// QR factorization. /// This is similar to the GEQRF and ORGQR LAPACK routines. - public void QRFactor(float[] r, int rowsR, int columnsR, float[] q) + public virtual void QRFactor(float[] r, int rowsR, int columnsR, float[] q) { if (r == null) { @@ -1468,7 +1468,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal /// work size value. /// This is similar to the GEQRF and ORGQR LAPACK routines. - public void QRFactor(float[] r, int rowsR, int columnsR, float[] q, float[] work) + public virtual void QRFactor(float[] r, int rowsR, int columnsR, float[] q, float[] work) { if (r == null) { @@ -1633,7 +1633,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The B matrix. /// The number of columns of B. /// On exit, the solution matrix. - public void QRSolve(float[] r, int rowsR, int columnsR, float[] q, float[] b, int columnsB, float[] x) + public virtual void QRSolve(float[] r, int rowsR, int columnsR, float[] q, float[] b, int columnsB, float[] x) { if (r == null) { @@ -1694,7 +1694,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The work array. The array must have a length of at least N, /// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal /// work size value. - public void QRSolve(float[] r, int rowsR, int columnsR, float[] q, float[] b, int columnsB, float[] x, float[] work) + public virtual void QRSolve(float[] r, int rowsR, int columnsR, float[] q, float[] b, int columnsB, float[] x, float[] work) { if (r == null) { @@ -1758,7 +1758,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The B matrix. /// The number of columns of B. /// On exit, the solution matrix. - public void QRSolveFactored(float[] q, float[] r, int rowsR, int columnsR, float[] b, int columnsB, float[] x) + public virtual void QRSolveFactored(float[] q, float[] r, int rowsR, int columnsR, float[] b, int columnsB, float[] x) { if (r == null) { @@ -1866,7 +1866,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// If is true, on exit VT contains the transposed /// right singular vectors. /// This is equivalent to the GESVD LAPACK routine. - public void SingularValueDecomposition(bool computeVectors, float[] a, int rowsA, int columnsA, float[] s, float[] u, float[] vt) + public virtual void SingularValueDecomposition(bool computeVectors, float[] a, int rowsA, int columnsA, float[] s, float[] u, float[] vt) { if (a == null) { @@ -1924,7 +1924,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// Max(3*Min(M, N) + Max(M, N), 5*Min(M,N)). For complex matrices, 2*Min(M, N) + Max(M, N). /// On exit, work[0] contains the optimal work size value. /// This is equivalent to the GESVD LAPACK routine. - public void SingularValueDecomposition(bool computeVectors, float[] a, int rowsA, int columnsA, float[] s, float[] u, float[] vt, float[] work) + public virtual void SingularValueDecomposition(bool computeVectors, float[] a, int rowsA, int columnsA, float[] s, float[] u, float[] vt, float[] work) { if (a == null) { @@ -2662,7 +2662,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The B matrix. /// The number of columns of B. /// On exit, the solution matrix. - public void SvdSolve(float[] a, int rowsA, int columnsA, float[] s, float[] u, float[] vt, float[] b, int columnsB, float[] x) + public virtual void SvdSolve(float[] a, int rowsA, int columnsA, float[] s, float[] u, float[] vt, float[] b, int columnsB, float[] x) { if (a == null) { @@ -2739,7 +2739,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The work array. For real matrices, the work array should be at least /// Max(3*Min(M, N) + Max(M, N), 5*Min(M,N)). For complex matrices, 2*Min(M, N) + Max(M, N). /// On exit, work[0] contains the optimal work size value. - public void SvdSolve(float[] a, int rowsA, int columnsA, float[] s, float[] u, float[] vt, float[] b, int columnsB, float[] x, float[] work) + public virtual void SvdSolve(float[] a, int rowsA, int columnsA, float[] s, float[] u, float[] vt, float[] b, int columnsB, float[] x, float[] work) { if (a == null) { @@ -2822,7 +2822,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// The B matrix. /// The number of columns of B. /// On exit, the solution matrix. - public void SvdSolveFactored(int rowsA, int columnsA, float[] s, float[] u, float[] vt, float[] b, int columnsB, float[] x) + public virtual void SvdSolveFactored(int rowsA, int columnsA, float[] s, float[] u, float[] vt, float[] b, int columnsB, float[] x) { if (s == null) { diff --git a/src/Numerics/Algorithms/LinearAlgebra/Mkl/MklLinearAlgebraProvider.Complex.tt b/src/Numerics/Algorithms/LinearAlgebra/Mkl/MklLinearAlgebraProvider.Complex.tt new file mode 100644 index 00000000..4e3521ba --- /dev/null +++ b/src/Numerics/Algorithms/LinearAlgebra/Mkl/MklLinearAlgebraProvider.Complex.tt @@ -0,0 +1,10 @@ +<#@ template language="C#" debug="true" #> +<#@ output extenstion="cs" #> +<# string library = "Mkl";#> +<# string dataType = "Complex";#> +<# string zero = "Complex.Zero";#> +<# string one = "Complex.One";#> +<# string prefix = "z";#> +<# string reff = "ref ";#> + +<#@ include file="..\NativeAlgebraProvider.include" #> \ No newline at end of file diff --git a/src/Numerics/Algorithms/LinearAlgebra/Mkl/MklLinearAlgebraProvider.Complex32.tt b/src/Numerics/Algorithms/LinearAlgebra/Mkl/MklLinearAlgebraProvider.Complex32.tt new file mode 100644 index 00000000..f8ef5284 --- /dev/null +++ b/src/Numerics/Algorithms/LinearAlgebra/Mkl/MklLinearAlgebraProvider.Complex32.tt @@ -0,0 +1,10 @@ +<#@ template language="C#" debug="true" #> +<#@ output extenstion="cs" #> +<# string library = "Mkl";#> +<# string dataType = "Complex32";#> +<# string zero = "Complex32.Zero";#> +<# string one = "Complex32.One";#> +<# string prefix = "c";#> +<# string reff = "ref ";#> + +<#@ include file="..\NativeAlgebraProvider.include" #> \ No newline at end of file diff --git a/src/Numerics/Algorithms/LinearAlgebra/Mkl/MklLinearAlgebraProvider.cs b/src/Numerics/Algorithms/LinearAlgebra/Mkl/MklLinearAlgebraProvider.cs deleted file mode 100644 index fdca19cc..00000000 --- a/src/Numerics/Algorithms/LinearAlgebra/Mkl/MklLinearAlgebraProvider.cs +++ /dev/null @@ -1,2591 +0,0 @@ -// -// Math.NET Numerics, part of the Math.NET Project -// http://mathnet.opensourcedotnet.info -// -// Copyright (c) 2009 Math.NET -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. -// - -/* This file is automatically generated - do not modify it. - Change NativeLinearAlgebraProvider.include instead. - Last generated on UTC 2010-07-06 18:34:52Z -*/ - -namespace MathNet.Numerics.Algorithms.LinearAlgebra.Mkl -{ - using System; - using System.Numerics; - using Properties; - - /// - /// The managed linear algebra provider. - /// - public class MklLinearAlgebraProvider : ILinearAlgebraProvider - { - - #region ILinearAlgebraProvider Members - - /// - /// Adds a scaled vector to another: y += alpha*x. - /// - /// The vector to update. - /// The value to scale by. - /// The vector to add to . - /// This equivalent to the AXPY BLAS routine. - public void AddVectorToScaledVector(double[] y, double alpha, double[] x) - { - if (y == null) - { - throw new ArgumentNullException("y"); - } - - if (x == null) - { - throw new ArgumentNullException("x"); - } - - if (y.Length != x.Length) - { - throw new ArgumentException(Resources.ArgumentVectorsSameLength); - } - - if (alpha == 0.0) - { - return; - } - - SafeNativeMethods.d_axpy(y.Length, alpha, x, y); - } - - /// - /// Scales an array. Can be used to scale a vector and a matrix. - /// - /// The scalar. - /// The values to scale. - /// This is equivalent to the SCAL BLAS routine. - public void ScaleArray(double alpha, double[] x) - { - if (x == null) - { - throw new ArgumentNullException("x"); - } - - if (alpha == 1.0) - { - return; - } - - SafeNativeMethods.d_scale(x.Length, alpha, x); - } - - /// - /// Computes the dot product of x and y. - /// - /// The vector x. - /// The vector y. - /// The dot product of x and y. - /// This is equivalent to the DOT BLAS routine. - public double DotProduct(double[] x, double[] y) - { - if (y == null) - { - throw new ArgumentNullException("y"); - } - - if (x == null) - { - throw new ArgumentNullException("x"); - } - - if (x.Length != y.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - - return SafeNativeMethods.d_dot_product(x.Length, x, y); - } - - /// - /// Does a point wise add of two arrays z = x + y. This can be used - /// to add vectors or matrices. - /// - /// The array x. - /// The array y. - /// The result of the addition. - /// There is no equivalent BLAS routine, but many libraries - /// provide optimized (parallel and/or vectorized) versions of this - /// routine. - public void AddArrays(double[] x, double[] y, double[] result) - { - if (y == null) - { - throw new ArgumentNullException("y"); - } - - if (x == null) - { - throw new ArgumentNullException("x"); - } - - if (x.Length != y.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - - if (x.Length != result.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - - SafeNativeMethods.d_vector_add( x.Length, x, y, result ); - } - - /// - /// Does a point wise subtraction of two arrays z = x - y. This can be used - /// to subtract vectors or matrices. - /// - /// The array x. - /// The array y. - /// The result of the subtraction. - /// There is no equivalent BLAS routine, but many libraries - /// provide optimized (parallel and/or vectorized) versions of this - /// routine. - public void SubtractArrays(double[] x, double[] y, double[] result) - { - if (y == null) - { - throw new ArgumentNullException("y"); - } - - if (x == null) - { - throw new ArgumentNullException("x"); - } - - if (x.Length != y.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - - if (x.Length != result.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - - SafeNativeMethods.d_vector_subtract( x.Length, x, y, result ); - } - - /// - /// Does a point wise multiplication of two arrays z = x * y. This can be used - /// to multiple elements of vectors or matrices. - /// - /// The array x. - /// The array y. - /// The result of the point wise multiplication. - /// There is no equivalent BLAS routine, but many libraries - /// provide optimized (parallel and/or vectorized) versions of this - /// routine. - public void PointWiseMultiplyArrays(double[] x, double[] y, double[] result) - { - if (y == null) - { - throw new ArgumentNullException("y"); - } - - if (x == null) - { - throw new ArgumentNullException("x"); - } - - if (x.Length != y.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - - if (x.Length != result.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - - SafeNativeMethods.d_vector_multiply( x.Length, x, y, result ); - } - - /// - /// Computes the requested of the matrix. - /// - /// The type of norm to compute. - /// The number of rows in the matrix. - /// The number of columns in the matrix. - /// The matrix to compute the norm from. - /// - /// The requested of the matrix. - /// - public double MatrixNorm(Norm norm, int rows, int columns, double[] matrix) - { - throw new NotImplementedException(); - } - - /// - /// Computes the requested of the matrix. - /// - /// The type of norm to compute. - /// The number of rows in the matrix. - /// The number of columns in the matrix. - /// The matrix to compute the norm from. - /// The work array. Only used when - /// and needs to be have a length of at least M (number of rows of . - /// - /// The requested of the matrix. - /// - public double MatrixNorm(Norm norm, int rows, int columns, double[] matrix, double[] work) - { - throw new NotImplementedException(); - } - - /// - /// Multiples two matrices. result = x * y - /// - /// The x matrix. - /// The number of rows in the x matrix. - /// The number of columns in the x matrix. - /// The y matrix. - /// The number of rows in the y matrix. - /// The number of columns in the y matrix. - /// Where to store the result of the multiplication. - /// This is a simplified version of the BLAS GEMM routine with alpha - /// set to 1.0 and beta set to 0.0, and x and y are not transposed. - public void MatrixMultiply(double[] x, int rowsX, int columnsX, double[] y, int rowsY, int columnsY, double[] result) - { - MatrixMultiplyWithUpdate(Transpose.DontTranspose, Transpose.DontTranspose, 1.0, x, rowsX, columnsX, y, rowsY, columnsY, 0.0, result); - } - - /// - /// Multiplies two matrices and updates another with the result. c = alpha*op(a)*op(b) + beta*c - /// - /// How to transpose the matrix. - /// How to transpose the matrix. - /// The value to scale matrix. - /// The a matrix. - /// The number of rows in the matrix. - /// The number of columns in the matrix. - /// The b matrix - /// The number of rows in the matrix. - /// The number of columns in the matrix. - /// The value to scale the matrix. - /// The c matrix. - public void MatrixMultiplyWithUpdate(Transpose transposeA, Transpose transposeB, double alpha, double[] a, - int rowsA, int columnsA, double[] b, int rowsB, int columnsB, double beta, double[] c) - { - if (a == null) - { - throw new ArgumentNullException("a"); - } - - if (b == null) - { - throw new ArgumentNullException("b"); - } - - if (c == null) - { - throw new ArgumentNullException("c"); - } - - var m = transposeA == Transpose.DontTranspose ? rowsA : columnsA; - var n = transposeB == Transpose.DontTranspose ? columnsB : rowsB; - var k = transposeA == Transpose.DontTranspose ? columnsA : rowsA; - - if( c.Length != rowsA * columnsB) - { - throw new ArgumentException(Resources.ArgumentMatrixDimensions); - } - - if (columnsA != rowsB) - { - throw new ArgumentException(Resources.ArgumentMatrixDimensions); - } - - SafeNativeMethods.d_matrix_multiply(transposeA, transposeB, m, n, k, alpha, a, b, beta, c); - } - - /// - /// Computes the LUP factorization of A. P*A = L*U. - /// - /// An by matrix. The matrix is overwritten with the - /// the LU factorization on exit. The lower triangular factor L is stored in under the diagonal of (the diagonal is always 1.0 - /// for the L factor). The upper triangular factor U is stored on and above the diagonal of . - /// The order of the square matrix . - /// On exit, it contains the pivot indices. The size of the array must be . - /// This is equivalent to the GETRF LAPACK routine. - public void LUFactor(double[] data, int order, int[] ipiv) - { - throw new NotImplementedException(); - } - - /// - /// Computes the inverse of matrix using LU factorization. - /// - /// The N by N matrix to invert. Contains the inverse On exit. - /// The order of the square matrix . - /// This is equivalent to the GETRF and GETRI LAPACK routines. - public void LUInverse(double[] a, int order) - { - throw new NotImplementedException(); - } - - /// - /// Computes the inverse of a previously factored matrix. - /// - /// The LU factored N by N matrix. Contains the inverse On exit. - /// The order of the square matrix . - /// The pivot indices of . - /// This is equivalent to the GETRI LAPACK routine. - public void LUInverseFactored(double[] a, int order, int[] ipiv) - { - throw new NotImplementedException(); - } - - /// - /// Computes the inverse of matrix using LU factorization. - /// - /// The N by N matrix to invert. Contains the inverse On exit. - /// The order of the square matrix . - /// The work array. The array must have a length of at least N, - /// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal - /// work size value. - /// This is equivalent to the GETRF and GETRI LAPACK routines. - public void LUInverse(double[] a, int order, double[] work) - { - throw new NotImplementedException(); - } - - /// - /// Computes the inverse of a previously factored matrix. - /// - /// The LU factored N by N matrix. Contains the inverse On exit. - /// The order of the square matrix . - /// The pivot indices of . - /// The work array. The array must have a length of at least N, - /// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal - /// work size value. - /// This is equivalent to the GETRI LAPACK routine. - public void LUInverseFactored(double[] a, int order, int[] ipiv, double[] work) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using LU factorization. - /// - /// The number of columns of B. - /// The square matrix A. - /// The order of the square matrix . - /// The B matrix. - /// This is equivalent to the GETRF and GETRS LAPACK routines. - public void LUSolve(int columnsOfB, double[] a, int order, double[] b) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using a previously factored A matrix. - /// - /// The number of columns of B. - /// The factored A matrix. - /// The order of the square matrix . - /// The pivot indices of . - /// The B matrix. - /// This is equivalent to the GETRS LAPACK routine. - public void LUSolveFactored(int columnsOfB, double[] a, int order, int[] ipiv, double[] b) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using LU factorization. - /// - /// How to transpose the matrix. - /// The number of columns of B. - /// The square matrix A. - /// The order of the square matrix . - /// The B matrix. - /// This is equivalent to the GETRF and GETRS LAPACK routines. - public void LUSolve(Transpose transposeA, int columnsOfB, double[] a, int order, double[] b) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using a previously factored A matrix. - /// - /// How to transpose the matrix. - /// The number of columns of B. - /// The factored A matrix. - /// The order of the square matrix . - /// The pivot indices of . - /// The B matrix. - /// This is equivalent to the GETRS LAPACK routine. - public void LUSolveFactored(Transpose transposeA, int columnsOfB, double[] a, int order, int[] ipiv, double[] b) - { - throw new NotImplementedException(); - } - - /// - /// Computes the Cholesky factorization of A. - /// - /// On entry, a square, positive definite matrix. On exit, the matrix is overwritten with the - /// the Cholesky factorization. - /// The number of rows or columns in the matrix. - /// This is equivalent to the POTRF LAPACK routine. - public void CholeskyFactor(double[] a, int order) - { - if (a == null) - { - throw new ArgumentNullException("a"); - } - - if (order < 1) - { - throw new ArgumentException(Resources.ArgumentMustBePositive, "order"); - } - - SafeNativeMethods.d_cholesky_factor(order, a); - } - - /// - /// Solves A*X=B for X using Cholesky factorization. - /// - /// The square, positive definite matrix A. - /// The number of rows and columns in A. - /// The B matrix. - /// The number of rows in the B matrix. - /// The number of columns in the B matrix. - /// This is equivalent to the POTRF add POTRS LAPACK routines. - /// - public void CholeskySolve(double[] a, int orderA, double[] b, int rowsB, int columnsB) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using a previously factored A matrix. - /// - /// The square, positive definite matrix A. - /// The number of rows and columns in A. - /// The B matrix. - /// The number of rows in the B matrix. - /// The number of columns in the B matrix. - /// This is equivalent to the POTRS LAPACK routine. - public void CholeskySolveFactored(double[] a, int orderA, double[] b, int rowsB, int columnsB) - { - throw new NotImplementedException(); - } - - /// - /// Computes the QR factorization of A. - /// - /// On entry, it is the M by N A matrix to factor. On exit, - /// it is overwritten with the R matrix of the QR factorization. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// On exit, A M by M matrix that holds the Q matrix of the - /// QR factorization. - /// This is similar to the GEQRF and ORGQR LAPACK routines. - public void QRFactor(double[] r, int rowsR, int columnsR, double[] q) - { - throw new NotImplementedException(); - } - - /// - /// Computes the QR factorization of A. - /// - /// On entry, it is the M by N A matrix to factor. On exit, - /// it is overwritten with the R matrix of the QR factorization. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// On exit, A M by M matrix that holds the Q matrix of the - /// QR factorization. - /// The work array. The array must have a length of at least N, - /// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal - /// work size value. - /// This is similar to the GEQRF and ORGQR LAPACK routines. - public void QRFactor(double[] r, int rowsR, int columnsR, double[] q, double[] work) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using QR factorization of A. - /// - /// On entry, it is the M by N A matrix to factor. On exit, - /// it is overwritten with the R matrix of the QR factorization. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// On exit, A M by M matrix that holds the Q matrix of the - /// QR factorization. - /// The B matrix. - /// The number of columns of B. - /// On exit, the solution matrix. - public void QRSolve(double[] r, int rowsR, int columnsR, double[] q, double[] b, int columnsB, double[] x) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using QR factorization of A. - /// - /// On entry, it is the M by N A matrix to factor. On exit, - /// it is overwritten with the R matrix of the QR factorization. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// On exit, A M by M matrix that holds the Q matrix of the - /// QR factorization. - /// The B matrix. - /// The number of columns of B. - /// On exit, the solution matrix. - /// The work array. The array must have a length of at least N, - /// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal - /// work size value. - public void QRSolve(double[] r, int rowsR, int columnsR, double[] q, double[] b, int columnsB, double[] x, double[] work) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using a previously QR factored matrix. - /// - /// The Q matrix obtained by calling . - /// The R matrix obtained by calling . - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// The B matrix. - /// The number of columns of B. - /// On exit, the solution matrix. - public void QRSolveFactored(double[] q, double[] r, int rowsR, int columnsR, double[] b, int columnsB, double[] x) - { - throw new NotImplementedException(); - } - - /// - /// Computes the singular value decomposition of A. - /// - /// Compute the singular U and VT vectors or not. - /// On entry, the M by N matrix to decompose. On exit, A may be overwritten. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// The singular values of A in ascending value. - /// If is true, on exit U contains the left - /// singular vectors. - /// If is true, on exit VT contains the transposed - /// right singular vectors. - /// This is equivalent to the GESVD LAPACK routine. - public void SingularValueDecomposition(bool computeVectors, double[] a, int rowsA, int columnsA, double[] s, double[] u, double[] vt) - { - throw new NotImplementedException(); - } - - /// - /// Computes the singular value decomposition of A. - /// - /// Compute the singular U and VT vectors or not. - /// On entry, the M by N matrix to decompose. On exit, A may be overwritten. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// The singular values of A in ascending value. - /// If is true, on exit U contains the left - /// singular vectors. - /// If is true, on exit VT contains the transposed - /// right singular vectors. - /// The work array. For real matrices, the work array should be at least - /// Max(3*Min(M, N) + Max(M, N), 5*Min(M,N)). For complex matrices, 2*Min(M, N) + Max(M, N). - /// On exit, work[0] contains the optimal work size value. - /// This is equivalent to the GESVD LAPACK routine. - public void SingularValueDecomposition(bool computeVectors, double[] a, int rowsA, int columnsA, double[] s, double[] u, double[] vt, double[] work) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using the singular value decomposition of A. - /// - /// On entry, the M by N matrix to decompose. On exit, A may be overwritten. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// The singular values of A in ascending value. - /// On exit U contains the left singular vectors. - /// On exit VT contains the transposed right singular vectors. - /// The B matrix. - /// The number of columns of B. - /// On exit, the solution matrix. - public void SvdSolve(double[] a, int rowsA, int columnsA, double[] s, double[] u, double[] vt, double[] b, int columnsB, double[] x) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using the singular value decomposition of A. - /// - /// On entry, the M by N matrix to decompose. On exit, A may be overwritten. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// The singular values of A in ascending value. - /// On exit U contains the left singular vectors. - /// On exit VT contains the transposed right singular vectors. - /// The B matrix. - /// The number of columns of B. - /// On exit, the solution matrix. - /// The work array. For real matrices, the work array should be at least - /// Max(3*Min(M, N) + Max(M, N), 5*Min(M,N)). For complex matrices, 2*Min(M, N) + Max(M, N). - /// On exit, work[0] contains the optimal work size value. - public void SvdSolve(double[] a, int rowsA, int columnsA, double[] s, double[] u, double[] vt, double[] b, int columnsB, double[] x, double[] work) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using a previously SVD decomposed matrix. - /// - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// The s values returned by . - /// The left singular vectors returned by . - /// The right singular vectors returned by . - /// The B matrix. - /// The number of columns of B. - /// On exit, the solution matrix. - public void SvdSolveFactored(int rowsA, int columnsA, double[] s, double[] u, double[] vt, double[] b, int columnsB, double[] x) - { - throw new NotImplementedException(); - } - - #endregion - - #region ILinearAlgebraProvider Members - - /// - /// Adds a scaled vector to another: y += alpha*x. - /// - /// The vector to update. - /// The value to scale by. - /// The vector to add to . - /// This equivalent to the AXPY BLAS routine. - public void AddVectorToScaledVector(float[] y, float alpha, float[] x) - { - if (y == null) - { - throw new ArgumentNullException("y"); - } - - if (x == null) - { - throw new ArgumentNullException("x"); - } - - if (y.Length != x.Length) - { - throw new ArgumentException(Resources.ArgumentVectorsSameLength); - } - - if (alpha == 0.0f) - { - return; - } - - SafeNativeMethods.s_axpy(y.Length, alpha, x, y); - } - - /// - /// Scales an array. Can be used to scale a vector and a matrix. - /// - /// The scalar. - /// The values to scale. - /// This is equivalent to the SCAL BLAS routine. - public void ScaleArray(float alpha, float[] x) - { - if (x == null) - { - throw new ArgumentNullException("x"); - } - - if (alpha == 1.0) - { - return; - } - - SafeNativeMethods.s_scale(x.Length, alpha, x); - } - - /// - /// Computes the dot product of x and y. - /// - /// The vector x. - /// The vector y. - /// The dot product of x and y. - /// This is equivalent to the DOT BLAS routine. - public float DotProduct(float[] x, float[] y) - { - if (y == null) - { - throw new ArgumentNullException("y"); - } - - if (x == null) - { - throw new ArgumentNullException("x"); - } - - if (x.Length != y.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - - return SafeNativeMethods.s_dot_product(x.Length, x, y); - } - - /// - /// Does a point wise add of two arrays z = x + y. This can be used - /// to add vectors or matrices. - /// - /// The array x. - /// The array y. - /// The result of the addition. - /// There is no equivalent BLAS routine, but many libraries - /// provide optimized (parallel and/or vectorized) versions of this - /// routine. - public void AddArrays(float[] x, float[] y, float[] result) - { - if (y == null) - { - throw new ArgumentNullException("y"); - } - - if (x == null) - { - throw new ArgumentNullException("x"); - } - - if (x.Length != y.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - - if (x.Length != result.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - - SafeNativeMethods.s_vector_add( x.Length, x, y, result ); - } - - /// - /// Does a point wise subtraction of two arrays z = x - y. This can be used - /// to subtract vectors or matrices. - /// - /// The array x. - /// The array y. - /// The result of the subtraction. - /// There is no equivalent BLAS routine, but many libraries - /// provide optimized (parallel and/or vectorized) versions of this - /// routine. - public void SubtractArrays(float[] x, float[] y, float[] result) - { - if (y == null) - { - throw new ArgumentNullException("y"); - } - - if (x == null) - { - throw new ArgumentNullException("x"); - } - - if (x.Length != y.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - - if (x.Length != result.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - - SafeNativeMethods.s_vector_subtract( x.Length, x, y, result ); - } - - /// - /// Does a point wise multiplication of two arrays z = x * y. This can be used - /// to multiple elements of vectors or matrices. - /// - /// The array x. - /// The array y. - /// The result of the point wise multiplication. - /// There is no equivalent BLAS routine, but many libraries - /// provide optimized (parallel and/or vectorized) versions of this - /// routine. - public void PointWiseMultiplyArrays(float[] x, float[] y, float[] result) - { - if (y == null) - { - throw new ArgumentNullException("y"); - } - - if (x == null) - { - throw new ArgumentNullException("x"); - } - - if (x.Length != y.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - - if (x.Length != result.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - - SafeNativeMethods.s_vector_multiply( x.Length, x, y, result ); - } - - /// - /// Computes the requested of the matrix. - /// - /// The type of norm to compute. - /// The number of rows in the matrix. - /// The number of columns in the matrix. - /// The matrix to compute the norm from. - /// - /// The requested of the matrix. - /// - public float MatrixNorm(Norm norm, int rows, int columns, float[] matrix) - { - throw new NotImplementedException(); - } - - /// - /// Computes the requested of the matrix. - /// - /// The type of norm to compute. - /// The number of rows in the matrix. - /// The number of columns in the matrix. - /// The matrix to compute the norm from. - /// The work array. Only used when - /// and needs to be have a length of at least M (number of rows of . - /// - /// The requested of the matrix. - /// - public float MatrixNorm(Norm norm, int rows, int columns, float[] matrix, float[] work) - { - throw new NotImplementedException(); - } - - /// - /// Multiples two matrices. result = x * y - /// - /// The x matrix. - /// The number of rows in the x matrix. - /// The number of columns in the x matrix. - /// The y matrix. - /// The number of rows in the y matrix. - /// The number of columns in the y matrix. - /// Where to store the result of the multiplication. - /// This is a simplified version of the BLAS GEMM routine with alpha - /// set to 1.0 and beta set to 0.0, and x and y are not transposed. - public void MatrixMultiply(float[] x, int rowsX, int columnsX, float[] y, int rowsY, int columnsY, float[] result) - { - MatrixMultiplyWithUpdate(Transpose.DontTranspose, Transpose.DontTranspose, 1.0f, x, rowsX, columnsX, y, rowsY, columnsY, 0.0f, result); - } - - /// - /// Multiplies two matrices and updates another with the result. c = alpha*op(a)*op(b) + beta*c - /// - /// How to transpose the matrix. - /// How to transpose the matrix. - /// The value to scale matrix. - /// The a matrix. - /// The number of rows in the matrix. - /// The number of columns in the matrix. - /// The b matrix - /// The number of rows in the matrix. - /// The number of columns in the matrix. - /// The value to scale the matrix. - /// The c matrix. - public void MatrixMultiplyWithUpdate(Transpose transposeA, Transpose transposeB, float alpha, float[] a, - int rowsA, int columnsA, float[] b, int rowsB, int columnsB, float beta, float[] c) - { - if (a == null) - { - throw new ArgumentNullException("a"); - } - - if (b == null) - { - throw new ArgumentNullException("b"); - } - - if (c == null) - { - throw new ArgumentNullException("c"); - } - - var m = transposeA == Transpose.DontTranspose ? rowsA : columnsA; - var n = transposeB == Transpose.DontTranspose ? columnsB : rowsB; - var k = transposeA == Transpose.DontTranspose ? columnsA : rowsA; - - if( c.Length != rowsA * columnsB) - { - throw new ArgumentException(Resources.ArgumentMatrixDimensions); - } - - if (columnsA != rowsB) - { - throw new ArgumentException(Resources.ArgumentMatrixDimensions); - } - - SafeNativeMethods.s_matrix_multiply(transposeA, transposeB, m, n, k, alpha, a, b, beta, c); - } - - /// - /// Computes the LUP factorization of A. P*A = L*U. - /// - /// An by matrix. The matrix is overwritten with the - /// the LU factorization on exit. The lower triangular factor L is stored in under the diagonal of (the diagonal is always 1.0 - /// for the L factor). The upper triangular factor U is stored on and above the diagonal of . - /// The order of the square matrix . - /// On exit, it contains the pivot indices. The size of the array must be . - /// This is equivalent to the GETRF LAPACK routine. - public void LUFactor(float[] data, int order, int[] ipiv) - { - throw new NotImplementedException(); - } - - /// - /// Computes the inverse of matrix using LU factorization. - /// - /// The N by N matrix to invert. Contains the inverse On exit. - /// The order of the square matrix . - /// This is equivalent to the GETRF and GETRI LAPACK routines. - public void LUInverse(float[] a, int order) - { - throw new NotImplementedException(); - } - - /// - /// Computes the inverse of a previously factored matrix. - /// - /// The LU factored N by N matrix. Contains the inverse On exit. - /// The order of the square matrix . - /// The pivot indices of . - /// This is equivalent to the GETRI LAPACK routine. - public void LUInverseFactored(float[] a, int order, int[] ipiv) - { - throw new NotImplementedException(); - } - - /// - /// Computes the inverse of matrix using LU factorization. - /// - /// The N by N matrix to invert. Contains the inverse On exit. - /// The order of the square matrix . - /// The work array. The array must have a length of at least N, - /// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal - /// work size value. - /// This is equivalent to the GETRF and GETRI LAPACK routines. - public void LUInverse(float[] a, int order, float[] work) - { - throw new NotImplementedException(); - } - - /// - /// Computes the inverse of a previously factored matrix. - /// - /// The LU factored N by N matrix. Contains the inverse On exit. - /// The order of the square matrix . - /// The pivot indices of . - /// The work array. The array must have a length of at least N, - /// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal - /// work size value. - /// This is equivalent to the GETRI LAPACK routine. - public void LUInverseFactored(float[] a, int order, int[] ipiv, float[] work) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using LU factorization. - /// - /// The number of columns of B. - /// The square matrix A. - /// The order of the square matrix . - /// The B matrix. - /// This is equivalent to the GETRF and GETRS LAPACK routines. - public void LUSolve(int columnsOfB, float[] a, int order, float[] b) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using a previously factored A matrix. - /// - /// The number of columns of B. - /// The factored A matrix. - /// The order of the square matrix . - /// The pivot indices of . - /// The B matrix. - /// This is equivalent to the GETRS LAPACK routine. - public void LUSolveFactored(int columnsOfB, float[] a, int order, int[] ipiv, float[] b) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using LU factorization. - /// - /// How to transpose the matrix. - /// The number of columns of B. - /// The square matrix A. - /// The order of the square matrix . - /// The B matrix. - /// This is equivalent to the GETRF and GETRS LAPACK routines. - public void LUSolve(Transpose transposeA, int columnsOfB, float[] a, int order, float[] b) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using a previously factored A matrix. - /// - /// How to transpose the matrix. - /// The number of columns of B. - /// The factored A matrix. - /// The order of the square matrix . - /// The pivot indices of . - /// The B matrix. - /// This is equivalent to the GETRS LAPACK routine. - public void LUSolveFactored(Transpose transposeA, int columnsOfB, float[] a, int order, int[] ipiv, float[] b) - { - throw new NotImplementedException(); - } - - /// - /// Computes the Cholesky factorization of A. - /// - /// On entry, a square, positive definite matrix. On exit, the matrix is overwritten with the - /// the Cholesky factorization. - /// The number of rows or columns in the matrix. - /// This is equivalent to the POTRF LAPACK routine. - public void CholeskyFactor(float[] a, int order) - { - if (a == null) - { - throw new ArgumentNullException("a"); - } - - if (order < 1) - { - throw new ArgumentException(Resources.ArgumentMustBePositive, "order"); - } - - SafeNativeMethods.s_cholesky_factor(order, a); - } - - /// - /// Solves A*X=B for X using Cholesky factorization. - /// - /// The square, positive definite matrix A. - /// The number of rows and columns in A. - /// The B matrix. - /// The number of rows in the B matrix. - /// The number of columns in the B matrix. - /// This is equivalent to the POTRF add POTRS LAPACK routines. - public void CholeskySolve(float[] a, int orderA, float[] b, int rowsB, int columnsB) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using a previously factored A matrix. - /// - /// The square, positive definite matrix A. - /// The number of rows and columns in A. - /// The B matrix. - /// The number of rows in the B matrix. - /// The number of columns in the B matrix. - /// This is equivalent to the POTRS LAPACK routine. - public void CholeskySolveFactored(float[] a, int orderA, float[] b, int rowsB, int columnsB) - { - throw new NotImplementedException(); - } - - /// - /// Computes the QR factorization of A. - /// - /// On entry, it is the M by N A matrix to factor. On exit, - /// it is overwritten with the R matrix of the QR factorization. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// On exit, A M by M matrix that holds the Q matrix of the - /// QR factorization. - /// This is similar to the GEQRF and ORGQR LAPACK routines. - public void QRFactor(float[] r, int rowsR, int columnsR, float[] q) - { - throw new NotImplementedException(); - } - - /// - /// Computes the QR factorization of A. - /// - /// On entry, it is the M by N A matrix to factor. On exit, - /// it is overwritten with the R matrix of the QR factorization. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// On exit, A M by M matrix that holds the Q matrix of the - /// QR factorization. - /// The work array. The array must have a length of at least N, - /// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal - /// work size value. - /// This is similar to the GEQRF and ORGQR LAPACK routines. - public void QRFactor(float[] r, int rowsR, int columnsR, float[] q, float[] work) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using QR factorization of A. - /// - /// On entry, it is the M by N A matrix to factor. On exit, - /// it is overwritten with the R matrix of the QR factorization. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// On exit, A M by M matrix that holds the Q matrix of the - /// QR factorization. - /// The B matrix. - /// The number of columns of B. - /// On exit, the solution matrix. - public void QRSolve(float[] r, int rowsR, int columnsR, float[] q, float[] b, int columnsB, float[] x) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using QR factorization of A. - /// - /// On entry, it is the M by N A matrix to factor. On exit, - /// it is overwritten with the R matrix of the QR factorization. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// On exit, A M by M matrix that holds the Q matrix of the - /// QR factorization. - /// The B matrix. - /// The number of columns of B. - /// On exit, the solution matrix. - /// The work array. The array must have a length of at least N, - /// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal - /// work size value. - public void QRSolve(float[] r, int rowsR, int columnsR, float[] q, float[] b, int columnsB, float[] x, float[] work) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using a previously QR factored matrix. - /// - /// The Q matrix obtained by calling . - /// The R matrix obtained by calling . - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// The B matrix. - /// The number of columns of B. - /// On exit, the solution matrix. - public void QRSolveFactored(float[] q, float[] r, int rowsR, int columnsR, float[] b, int columnsB, float[] x) - { - throw new NotImplementedException(); - } - - /// - /// Computes the singular value decomposition of A. - /// - /// Compute the singular U and VT vectors or not. - /// On entry, the M by N matrix to decompose. On exit, A may be overwritten. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// The singular values of A in ascending value. - /// If is true, on exit U contains the left - /// singular vectors. - /// If is true, on exit VT contains the transposed - /// right singular vectors. - /// This is equivalent to the GESVD LAPACK routine. - public void SingularValueDecomposition(bool computeVectors, float[] a, int rowsA, int columnsA, float[] s, float[] u, float[] vt) - { - throw new NotImplementedException(); - } - - /// - /// Computes the singular value decomposition of A. - /// - /// Compute the singular U and VT vectors or not. - /// On entry, the M by N matrix to decompose. On exit, A may be overwritten. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// The singular values of A in ascending value. - /// If is true, on exit U contains the left - /// singular vectors. - /// If is true, on exit VT contains the transposed - /// right singular vectors. - /// The work array. For real matrices, the work array should be at least - /// Max(3*Min(M, N) + Max(M, N), 5*Min(M,N)). For complex matrices, 2*Min(M, N) + Max(M, N). - /// On exit, work[0] contains the optimal work size value. - /// This is equivalent to the GESVD LAPACK routine. - public void SingularValueDecomposition(bool computeVectors, float[] a, int rowsA, int columnsA, float[] s, float[] u, float[] vt, float[] work) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using the singular value decomposition of A. - /// - /// On entry, the M by N matrix to decompose. On exit, A may be overwritten. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// The singular values of A in ascending value. - /// On exit U contains the left singular vectors. - /// On exit VT contains the transposed right singular vectors. - /// The B matrix. - /// The number of columns of B. - /// On exit, the solution matrix. - public void SvdSolve(float[] a, int rowsA, int columnsA, float[] s, float[] u, float[] vt, float[] b, int columnsB, float[] x) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using the singular value decomposition of A. - /// - /// On entry, the M by N matrix to decompose. On exit, A may be overwritten. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// The singular values of A in ascending value. - /// On exit U contains the left singular vectors. - /// On exit VT contains the transposed right singular vectors. - /// The B matrix. - /// The number of columns of B. - /// On exit, the solution matrix. - /// The work array. For real matrices, the work array should be at least - /// Max(3*Min(M, N) + Max(M, N), 5*Min(M,N)). For complex matrices, 2*Min(M, N) + Max(M, N). - /// On exit, work[0] contains the optimal work size value. - public void SvdSolve(float[] a, int rowsA, int columnsA, float[] s, float[] u, float[] vt, float[] b, int columnsB, float[] x, float[] work) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using a previously SVD decomposed matrix. - /// - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// The s values returned by . - /// The left singular vectors returned by . - /// The right singular vectors returned by . - /// The B matrix. - /// The number of columns of B. - /// On exit, the solution matrix. - public void SvdSolveFactored(int rowsA, int columnsA, float[] s, float[] u, float[] vt, float[] b, int columnsB, float[] x) - { - throw new NotImplementedException(); - } - - #endregion - - #region ILinearAlgebraProvider Members - - /// - /// Adds a scaled vector to another: y += alpha*x. - /// - /// The vector to update. - /// The value to scale by. - /// The vector to add to . - /// This equivalent to the AXPY BLAS routine. - public void AddVectorToScaledVector(Complex[] y, Complex alpha, Complex[] x) - { - if (y == null) - { - throw new ArgumentNullException("y"); - } - - if (x == null) - { - throw new ArgumentNullException("x"); - } - - if (y.Length != x.Length) - { - throw new ArgumentException(Resources.ArgumentVectorsSameLength); - } - - if (alpha.IsZero()) - { - return; - } - - SafeNativeMethods.z_axpy(y.Length, ref alpha, x, y); - } - - /// - /// Scales an array. Can be used to scale a vector and a matrix. - /// - /// The scalar. - /// The values to scale. - /// This is equivalent to the SCAL BLAS routine. - public void ScaleArray(Complex alpha, Complex[] x) - { - if (x == null) - { - throw new ArgumentNullException("x"); - } - - if (alpha.IsOne()) - { - return; - } - - SafeNativeMethods.z_scale(x.Length, ref alpha, x); - } - - /// - /// Computes the dot product of x and y. - /// - /// The vector x. - /// The vector y. - /// The dot product of x and y. - /// This is equivalent to the DOT BLAS routine. - public Complex DotProduct(Complex[] x, Complex[] y) - { - if (y == null) - { - throw new ArgumentNullException("y"); - } - - if (x == null) - { - throw new ArgumentNullException("x"); - } - - if (x.Length != y.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - - return SafeNativeMethods.z_dot_product(x.Length, x, y); - } - - /// - /// Does a point wise add of two arrays z = x + y. This can be used - /// to add vectors or matrices. - /// - /// The array x. - /// The array y. - /// The result of the addition. - /// There is no equivalent BLAS routine, but many libraries - /// provide optimized (parallel and/or vectorized) versions of this - /// routine. - public void AddArrays(Complex[] x, Complex[] y, Complex[] result) - { - if (y == null) - { - throw new ArgumentNullException("y"); - } - - if (x == null) - { - throw new ArgumentNullException("x"); - } - - if (x.Length != y.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - - if (x.Length != result.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - - SafeNativeMethods.z_vector_add( x.Length, x, y, result ); - } - - /// - /// Does a point wise subtraction of two arrays z = x - y. This can be used - /// to subtract vectors or matrices. - /// - /// The array x. - /// The array y. - /// The result of the subtraction. - /// There is no equivalent BLAS routine, but many libraries - /// provide optimized (parallel and/or vectorized) versions of this - /// routine. - public void SubtractArrays(Complex[] x, Complex[] y, Complex[] result) - { - if (y == null) - { - throw new ArgumentNullException("y"); - } - - if (x == null) - { - throw new ArgumentNullException("x"); - } - - if (x.Length != y.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - - if (x.Length != result.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - - SafeNativeMethods.z_vector_subtract( x.Length, x, y, result ); - } - - /// - /// Does a point wise multiplication of two arrays z = x * y. This can be used - /// to multiple elements of vectors or matrices. - /// - /// The array x. - /// The array y. - /// The result of the point wise multiplication. - /// There is no equivalent BLAS routine, but many libraries - /// provide optimized (parallel and/or vectorized) versions of this - /// routine. - public void PointWiseMultiplyArrays(Complex[] x, Complex[] y, Complex[] result) - { - if (y == null) - { - throw new ArgumentNullException("y"); - } - - if (x == null) - { - throw new ArgumentNullException("x"); - } - - if (x.Length != y.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - - if (x.Length != result.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - - SafeNativeMethods.z_vector_multiply( x.Length, x, y, result ); - } - - /// - /// Computes the requested of the matrix. - /// - /// The type of norm to compute. - /// The number of rows in the matrix. - /// The number of columns in the matrix. - /// The matrix to compute the norm from. - /// - /// The requested of the matrix. - /// - public Complex MatrixNorm(Norm norm, int rows, int columns, Complex[] matrix) - { - throw new NotImplementedException(); - } - - /// - /// Computes the requested of the matrix. - /// - /// The type of norm to compute. - /// The number of rows in the matrix. - /// The number of columns in the matrix. - /// The matrix to compute the norm from. - /// The work array. Only used when - /// and needs to be have a length of at least M (number of rows of . - /// - /// The requested of the matrix. - /// - public Complex MatrixNorm(Norm norm, int rows, int columns, Complex[] matrix, Complex[] work) - { - throw new NotImplementedException(); - } - - /// - /// Multiples two matrices. result = x * y - /// - /// The x matrix. - /// The number of rows in the x matrix. - /// The number of columns in the x matrix. - /// The y matrix. - /// The number of rows in the y matrix. - /// The number of columns in the y matrix. - /// Where to store the result of the multiplication. - /// This is a simplified version of the BLAS GEMM routine with alpha - /// set to 1.0 and beta set to 0.0, and x and y are not transposed. - public void MatrixMultiply(Complex[] x, int rowsX, int columnsX, Complex[] y, int rowsY, int columnsY, Complex[] result) - { - MatrixMultiplyWithUpdate(Transpose.DontTranspose, Transpose.DontTranspose, Complex.One, x, rowsX, columnsX, y, rowsY, columnsY, Complex.Zero, result); - } - - /// - /// Multiplies two matrices and updates another with the result. c = alpha*op(a)*op(b) + beta*c - /// - /// How to transpose the matrix. - /// How to transpose the matrix. - /// The value to scale matrix. - /// The a matrix. - /// The number of rows in the matrix. - /// The number of columns in the matrix. - /// The b matrix - /// The number of rows in the matrix. - /// The number of columns in the matrix. - /// The value to scale the matrix. - /// The c matrix. - public void MatrixMultiplyWithUpdate(Transpose transposeA, Transpose transposeB, Complex alpha, Complex[] a, - int rowsA, int columnsA, Complex[] b, int rowsB, int columnsB, Complex beta, Complex[] c) - { - if (a == null) - { - throw new ArgumentNullException("a"); - } - - if (b == null) - { - throw new ArgumentNullException("b"); - } - - if (c == null) - { - throw new ArgumentNullException("c"); - } - - var m = transposeA == Transpose.DontTranspose ? rowsA : columnsA; - var n = transposeB == Transpose.DontTranspose ? columnsB : rowsB; - var k = transposeA == Transpose.DontTranspose ? columnsA : rowsA; - - if( c.Length != rowsA * columnsB) - { - throw new ArgumentException(Resources.ArgumentMatrixDimensions); - } - - if (columnsA != rowsB) - { - throw new ArgumentException(Resources.ArgumentMatrixDimensions); - } - - SafeNativeMethods.z_matrix_multiply(transposeA, transposeB, m, n, k, ref alpha, a, b, ref beta, c); - } - - /// - /// Computes the LUP factorization of A. P*A = L*U. - /// - /// An by matrix. The matrix is overwritten with the - /// the LU factorization on exit. The lower triangular factor L is stored in under the diagonal of (the diagonal is always 1.0 - /// for the L factor). The upper triangular factor U is stored on and above the diagonal of . - /// The order of the square matrix . - /// On exit, it contains the pivot indices. The size of the array must be . - /// This is equivalent to the GETRF LAPACK routine. - public void LUFactor(Complex[] data, int order, int[] ipiv) - { - throw new NotImplementedException(); - } - - /// - /// Computes the inverse of matrix using LU factorization. - /// - /// The N by N matrix to invert. Contains the inverse On exit. - /// The order of the square matrix . - /// This is equivalent to the GETRF and GETRI LAPACK routines. - public void LUInverse(Complex[] a, int order) - { - throw new NotImplementedException(); - } - - /// - /// Computes the inverse of a previously factored matrix. - /// - /// The LU factored N by N matrix. Contains the inverse On exit. - /// The order of the square matrix . - /// The pivot indices of . - /// This is equivalent to the GETRI LAPACK routine. - public void LUInverseFactored(Complex[] a, int order, int[] ipiv) - { - throw new NotImplementedException(); - } - - /// - /// Computes the inverse of matrix using LU factorization. - /// - /// The N by N matrix to invert. Contains the inverse On exit. - /// The order of the square matrix . - /// The work array. The array must have a length of at least N, - /// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal - /// work size value. - /// This is equivalent to the GETRF and GETRI LAPACK routines. - public void LUInverse(Complex[] a, int order, Complex[] work) - { - throw new NotImplementedException(); - } - - /// - /// Computes the inverse of a previously factored matrix. - /// - /// The LU factored N by N matrix. Contains the inverse On exit. - /// The order of the square matrix . - /// The pivot indices of . - /// The work array. The array must have a length of at least N, - /// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal - /// work size value. - /// This is equivalent to the GETRI LAPACK routine. - public void LUInverseFactored(Complex[] a, int order, int[] ipiv, Complex[] work) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using LU factorization. - /// - /// The number of columns of B. - /// The square matrix A. - /// The order of the square matrix . - /// The B matrix. - /// This is equivalent to the GETRF and GETRS LAPACK routines. - public void LUSolve(int columnsOfB, Complex[] a, int order, Complex[] b) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using a previously factored A matrix. - /// - /// The number of columns of B. - /// The factored A matrix. - /// The order of the square matrix . - /// The pivot indices of . - /// The B matrix. - /// This is equivalent to the GETRS LAPACK routine. - public void LUSolveFactored(int columnsOfB, Complex[] a, int order, int[] ipiv, Complex[] b) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using LU factorization. - /// - /// How to transpose the matrix. - /// The number of columns of B. - /// The square matrix A. - /// The order of the square matrix . - /// The B matrix. - /// This is equivalent to the GETRF and GETRS LAPACK routines. - public void LUSolve(Transpose transposeA, int columnsOfB, Complex[] a, int order, Complex[] b) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using a previously factored A matrix. - /// - /// How to transpose the matrix. - /// The number of columns of B. - /// The factored A matrix. - /// The order of the square matrix . - /// The pivot indices of . - /// The B matrix. - /// This is equivalent to the GETRS LAPACK routine. - public void LUSolveFactored(Transpose transposeA, int columnsOfB, Complex[] a, int order, int[] ipiv, Complex[] b) - { - throw new NotImplementedException(); - } - - /// - /// Computes the Cholesky factorization of A. - /// - /// On entry, a square, positive definite matrix. On exit, the matrix is overwritten with the - /// the Cholesky factorization. - /// The number of rows or columns in the matrix. - /// This is equivalent to the POTRF LAPACK routine. - public void CholeskyFactor(Complex[] a, int order) - { - if (a == null) - { - throw new ArgumentNullException("a"); - } - - if (order < 1) - { - throw new ArgumentException(Resources.ArgumentMustBePositive, "order"); - } - - SafeNativeMethods.z_cholesky_factor(order, a); - } - - /// - /// Solves A*X=B for X using Cholesky factorization. - /// - /// The square, positive definite matrix A. - /// The number of rows and columns in A. - /// The B matrix. - /// The number of rows in the B matrix. - /// The number of columns in the B matrix. - /// This is equivalent to the POTRF add POTRS LAPACK routines. - public void CholeskySolve(Complex[] a, int orderA, Complex[] b, int rowsB, int columnsB) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using a previously factored A matrix. - /// - /// The square, positive definite matrix A. - /// The number of rows and columns in A. - /// The B matrix. - /// The number of rows in the B matrix. - /// The number of columns in the B matrix. - /// This is equivalent to the POTRS LAPACK routine. - public void CholeskySolveFactored(Complex[] a, int orderA, Complex[] b, int rowsB, int columnsB) - { - throw new NotImplementedException(); - } - - /// - /// Computes the QR factorization of A. - /// - /// On entry, it is the M by N A matrix to factor. On exit, - /// it is overwritten with the R matrix of the QR factorization. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// On exit, A M by M matrix that holds the Q matrix of the - /// QR factorization. - /// This is similar to the GEQRF and ORGQR LAPACK routines. - public void QRFactor(Complex[] r, int rowsR, int columnsR, Complex[] q) - { - throw new NotImplementedException(); - } - - /// - /// Computes the QR factorization of A. - /// - /// On entry, it is the M by N A matrix to factor. On exit, - /// it is overwritten with the R matrix of the QR factorization. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// On exit, A M by M matrix that holds the Q matrix of the - /// QR factorization. - /// The work array. The array must have a length of at least N, - /// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal - /// work size value. - /// This is similar to the GEQRF and ORGQR LAPACK routines. - public void QRFactor(Complex[] r, int rowsR, int columnsR, Complex[] q, Complex[] work) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using QR factorization of A. - /// - /// On entry, it is the M by N A matrix to factor. On exit, - /// it is overwritten with the R matrix of the QR factorization. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// On exit, A M by M matrix that holds the Q matrix of the - /// QR factorization. - /// The B matrix. - /// The number of columns of B. - /// On exit, the solution matrix. - public void QRSolve(Complex[] r, int rowsR, int columnsR, Complex[] q, Complex[] b, int columnsB, Complex[] x) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using QR factorization of A. - /// - /// On entry, it is the M by N A matrix to factor. On exit, - /// it is overwritten with the R matrix of the QR factorization. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// On exit, A M by M matrix that holds the Q matrix of the - /// QR factorization. - /// The B matrix. - /// The number of columns of B. - /// On exit, the solution matrix. - /// The work array. The array must have a length of at least N, - /// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal - /// work size value. - public void QRSolve(Complex[] r, int rowsR, int columnsR, Complex[] q, Complex[] b, int columnsB, Complex[] x, Complex[] work) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using a previously QR factored matrix. - /// - /// The Q matrix obtained by calling . - /// The R matrix obtained by calling . - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// The B matrix. - /// The number of columns of B. - /// On exit, the solution matrix. - public void QRSolveFactored(Complex[] q, Complex[] r, int rowsR, int columnsR, Complex[] b, int columnsB, Complex[] x) - { - throw new NotImplementedException(); - } - - /// - /// Computes the singular value decomposition of A. - /// - /// Compute the singular U and VT vectors or not. - /// On entry, the M by N matrix to decompose. On exit, A may be overwritten. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// The singular values of A in ascending value. - /// If is true, on exit U contains the left - /// singular vectors. - /// If is true, on exit VT contains the transposed - /// right singular vectors. - /// This is equivalent to the GESVD LAPACK routine. - public void SingularValueDecomposition(bool computeVectors, Complex[] a, int rowsA, int columnsA, Complex[] s, Complex[] u, Complex[] vt) - { - throw new NotImplementedException(); - } - - /// - /// Computes the singular value decomposition of A. - /// - /// Compute the singular U and VT vectors or not. - /// On entry, the M by N matrix to decompose. On exit, A may be overwritten. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// The singular values of A in ascending value. - /// If is true, on exit U contains the left - /// singular vectors. - /// If is true, on exit VT contains the transposed - /// right singular vectors. - /// The work array. For real matrices, the work array should be at least - /// Max(3*Min(M, N) + Max(M, N), 5*Min(M,N)). For complex matrices, 2*Min(M, N) + Max(M, N). - /// On exit, work[0] contains the optimal work size value. - /// This is equivalent to the GESVD LAPACK routine. - public void SingularValueDecomposition(bool computeVectors, Complex[] a, int rowsA, int columnsA, Complex[] s, Complex[] u, Complex[] vt, Complex[] work) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using the singular value decomposition of A. - /// - /// On entry, the M by N matrix to decompose. On exit, A may be overwritten. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// The singular values of A in ascending value. - /// On exit U contains the left singular vectors. - /// On exit VT contains the transposed right singular vectors. - /// The B matrix. - /// The number of columns of B. - /// On exit, the solution matrix. - public void SvdSolve(Complex[] a, int rowsA, int columnsA, Complex[] s, Complex[] u, Complex[] vt, Complex[] b, int columnsB, Complex[] x) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using the singular value decomposition of A. - /// - /// On entry, the M by N matrix to decompose. On exit, A may be overwritten. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// The singular values of A in ascending value. - /// On exit U contains the left singular vectors. - /// On exit VT contains the transposed right singular vectors. - /// The B matrix. - /// The number of columns of B. - /// On exit, the solution matrix. - /// The work array. For real matrices, the work array should be at least - /// Max(3*Min(M, N) + Max(M, N), 5*Min(M,N)). For complex matrices, 2*Min(M, N) + Max(M, N). - /// On exit, work[0] contains the optimal work size value. - public void SvdSolve(Complex[] a, int rowsA, int columnsA, Complex[] s, Complex[] u, Complex[] vt, Complex[] b, int columnsB, Complex[] x, Complex[] work) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using a previously SVD decomposed matrix. - /// - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// The s values returned by . - /// The left singular vectors returned by . - /// The right singular vectors returned by . - /// The B matrix. - /// The number of columns of B. - /// On exit, the solution matrix. - public void SvdSolveFactored(int rowsA, int columnsA, Complex[] s, Complex[] u, Complex[] vt, Complex[] b, int columnsB, Complex[] x) - { - throw new NotImplementedException(); - } - - #endregion - - #region ILinearAlgebraProvider Members - - /// - /// Adds a scaled vector to another: y += alpha*x. - /// - /// The vector to update. - /// The value to scale by. - /// The vector to add to . - /// This equivalent to the AXPY BLAS routine. - public void AddVectorToScaledVector(Complex32[] y, Complex32 alpha, Complex32[] x) - { - if (y == null) - { - throw new ArgumentNullException("y"); - } - - if (x == null) - { - throw new ArgumentNullException("x"); - } - - if (y.Length != x.Length) - { - throw new ArgumentException(Resources.ArgumentVectorsSameLength); - } - - if (alpha.IsZero()) - { - return; - } - - SafeNativeMethods.c_axpy(y.Length, ref alpha, x, y); - } - - /// - /// Scales an array. Can be used to scale a vector and a matrix. - /// - /// The scalar. - /// The values to scale. - /// This is equivalent to the SCAL BLAS routine. - public void ScaleArray(Complex32 alpha, Complex32[] x) - { - if (x == null) - { - throw new ArgumentNullException("x"); - } - - if (alpha.IsOne()) - { - return; - } - - SafeNativeMethods.c_scale(x.Length, ref alpha, x); - } - - /// - /// Computes the dot product of x and y. - /// - /// The vector x. - /// The vector y. - /// The dot product of x and y. - /// This is equivalent to the DOT BLAS routine. - public Complex32 DotProduct(Complex32[] x, Complex32[] y) - { - if (y == null) - { - throw new ArgumentNullException("y"); - } - - if (x == null) - { - throw new ArgumentNullException("x"); - } - - if (x.Length != y.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - - return SafeNativeMethods.c_dot_product(x.Length, x, y); - } - - /// - /// Does a point wise add of two arrays z = x + y. This can be used - /// to add vectors or matrices. - /// - /// The array x. - /// The array y. - /// The result of the addition. - /// There is no equivalent BLAS routine, but many libraries - /// provide optimized (parallel and/or vectorized) versions of this - /// routine. - public void AddArrays(Complex32[] x, Complex32[] y, Complex32[] result) - { - if (y == null) - { - throw new ArgumentNullException("y"); - } - - if (x == null) - { - throw new ArgumentNullException("x"); - } - - if (x.Length != y.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - - if (x.Length != result.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - - SafeNativeMethods.c_vector_add( x.Length, x, y, result ); - } - - /// - /// Does a point wise subtraction of two arrays z = x - y. This can be used - /// to subtract vectors or matrices. - /// - /// The array x. - /// The array y. - /// The result of the subtraction. - /// There is no equivalent BLAS routine, but many libraries - /// provide optimized (parallel and/or vectorized) versions of this - /// routine. - public void SubtractArrays(Complex32[] x, Complex32[] y, Complex32[] result) - { - if (y == null) - { - throw new ArgumentNullException("y"); - } - - if (x == null) - { - throw new ArgumentNullException("x"); - } - - if (x.Length != y.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - - if (x.Length != result.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - - SafeNativeMethods.c_vector_subtract( x.Length, x, y, result ); - } - - /// - /// Does a point wise multiplication of two arrays z = x * y. This can be used - /// to multiple elements of vectors or matrices. - /// - /// The array x. - /// The array y. - /// The result of the point wise multiplication. - /// There is no equivalent BLAS routine, but many libraries - /// provide optimized (parallel and/or vectorized) versions of this - /// routine. - public void PointWiseMultiplyArrays(Complex32[] x, Complex32[] y, Complex32[] result) - { - if (y == null) - { - throw new ArgumentNullException("y"); - } - - if (x == null) - { - throw new ArgumentNullException("x"); - } - - if (x.Length != y.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - - if (x.Length != result.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - - SafeNativeMethods.c_vector_multiply( x.Length, x, y, result ); - } - - /// - /// Computes the requested of the matrix. - /// - /// The type of norm to compute. - /// The number of rows. - /// The number of columns. - /// The matrix to compute the norm from. - /// - /// The requested of the matrix. - /// - public Complex32 MatrixNorm(Norm norm, int rows, int columns, Complex32[] matrix) - { - throw new NotImplementedException(); - } - - /// - /// Computes the requested of the matrix. - /// - /// The type of norm to compute. - /// The number of rows. - /// The number of columns. - /// The matrix to compute the norm from. - /// The work array. Only used when - /// and needs to be have a length of at least M (number of rows of . - /// - /// The requested of the matrix. - /// - public Complex32 MatrixNorm(Norm norm, int rows, int columns, Complex32[] matrix, Complex32[] work) - { - throw new NotImplementedException(); - } - - /// - /// Multiples two matrices. result = x * y - /// - /// The x matrix. - /// The number of rows in the x matrix. - /// The number of columns in the x matrix. - /// The y matrix. - /// The number of rows in the y matrix. - /// The number of columns in the y matrix. - /// Where to store the result of the multiplication. - /// This is a simplified version of the BLAS GEMM routine with alpha - /// set to 1.0 and beta set to 0.0, and x and y are not transposed. - public void MatrixMultiply(Complex32[] x, int rowsX, int columnsX, Complex32[] y, int rowsY, int columnsY, Complex32[] result) - { - MatrixMultiplyWithUpdate(Transpose.DontTranspose, Transpose.DontTranspose, Complex32.One, x, rowsX, columnsX, y, rowsY, columnsY, Complex32.Zero, result); - } - - /// - /// Multiplies two matrices and updates another with the result. c = alpha*op(a)*op(b) + beta*c - /// - /// How to transpose the matrix. - /// How to transpose the matrix. - /// The value to scale matrix. - /// The a matrix. - /// The number of rows in the matrix. - /// The number of columns in the matrix. - /// The b matrix - /// The number of rows in the matrix. - /// The number of columns in the matrix. - /// The value to scale the matrix. - /// The c matrix. - public void MatrixMultiplyWithUpdate(Transpose transposeA, Transpose transposeB, Complex32 alpha, Complex32[] a, - int rowsA, int columnsA, Complex32[] b, int rowsB, int columnsB, Complex32 beta, Complex32[] c) - { - if (a == null) - { - throw new ArgumentNullException("a"); - } - - if (b == null) - { - throw new ArgumentNullException("b"); - } - - if (c == null) - { - throw new ArgumentNullException("c"); - } - - var m = transposeA == Transpose.DontTranspose ? rowsA : columnsA; - var n = transposeB == Transpose.DontTranspose ? columnsB : rowsB; - var k = transposeA == Transpose.DontTranspose ? columnsA : rowsA; - - if( c.Length != rowsA * columnsB) - { - throw new ArgumentException(Resources.ArgumentMatrixDimensions); - } - - if (columnsA != rowsB) - { - throw new ArgumentException(Resources.ArgumentMatrixDimensions); - } - - SafeNativeMethods.c_matrix_multiply(transposeA, transposeB, m, n, k, ref alpha, a, b, ref beta, c); - } - - /// - /// Computes the LUP factorization of A. P*A = L*U. - /// - /// An by matrix. The matrix is overwritten with the - /// the LU factorization on exit. The lower triangular factor L is stored in under the diagonal of (the diagonal is always 1.0 - /// for the L factor). The upper triangular factor U is stored on and above the diagonal of . - /// The order of the square matrix . - /// On exit, it contains the pivot indices. The size of the array must be . - /// This is equivalent to the GETRF LAPACK routine. - public void LUFactor(Complex32[] data, int order, int[] ipiv) - { - throw new NotImplementedException(); - } - - /// - /// Computes the inverse of matrix using LU factorization. - /// - /// The N by N matrix to invert. Contains the inverse On exit. - /// The order of the square matrix . - /// This is equivalent to the GETRF and GETRI LAPACK routines. - public void LUInverse(Complex32[] a, int order) - { - throw new NotImplementedException(); - } - - /// - /// Computes the inverse of a previously factored matrix. - /// - /// The LU factored N by N matrix. Contains the inverse On exit. - /// The order of the square matrix . - /// The pivot indices of . - /// This is equivalent to the GETRI LAPACK routine. - public void LUInverseFactored(Complex32[] a, int order, int[] ipiv) - { - throw new NotImplementedException(); - } - - /// - /// Computes the inverse of matrix using LU factorization. - /// - /// The N by N matrix to invert. Contains the inverse On exit. - /// The order of the square matrix . - /// The work array. The array must have a length of at least N, - /// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal - /// work size value. - /// This is equivalent to the GETRF and GETRI LAPACK routines. - public void LUInverse(Complex32[] a, int order, Complex32[] work) - { - throw new NotImplementedException(); - } - - /// - /// Computes the inverse of a previously factored matrix. - /// - /// The LU factored N by N matrix. Contains the inverse On exit. - /// The order of the square matrix . - /// The pivot indices of . - /// The work array. The array must have a length of at least N, - /// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal - /// work size value. - /// This is equivalent to the GETRI LAPACK routine. - public void LUInverseFactored(Complex32[] a, int order, int[] ipiv, Complex32[] work) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using LU factorization. - /// - /// The number of columns of B. - /// The square matrix A. - /// The order of the square matrix . - /// The B matrix. - /// This is equivalent to the GETRF and GETRS LAPACK routines. - public void LUSolve(int columnsOfB, Complex32[] a, int order, Complex32[] b) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using a previously factored A matrix. - /// - /// The number of columns of B. - /// The factored A matrix. - /// The order of the square matrix . - /// The pivot indices of . - /// The B matrix. - /// This is equivalent to the GETRS LAPACK routine. - public void LUSolveFactored(int columnsOfB, Complex32[] a, int order, int[] ipiv, Complex32[] b) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using LU factorization. - /// - /// How to transpose the matrix. - /// The number of columns of B. - /// The square matrix A. - /// The order of the square matrix . - /// The B matrix. - /// This is equivalent to the GETRF and GETRS LAPACK routines. - public void LUSolve(Transpose transposeA, int columnsOfB, Complex32[] a, int order, Complex32[] b) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using a previously factored A matrix. - /// - /// How to transpose the matrix. - /// The number of columns of B. - /// The factored A matrix. - /// The order of the square matrix . - /// The pivot indices of . - /// The B matrix. - /// This is equivalent to the GETRS LAPACK routine. - public void LUSolveFactored(Transpose transposeA, int columnsOfB, Complex32[] a, int order, int[] ipiv, Complex32[] b) - { - throw new NotImplementedException(); - } - - /// - /// Computes the Cholesky factorization of A. - /// - /// On entry, a square, positive definite matrix. On exit, the matrix is overwritten with the - /// the Cholesky factorization. - /// The number of rows or columns in the matrix. - /// This is equivalent to the POTRF LAPACK routine. - public void CholeskyFactor(Complex32[] a, int order) - { - if (a == null) - { - throw new ArgumentNullException("a"); - } - - if (order < 1) - { - throw new ArgumentException(Resources.ArgumentMustBePositive, "order"); - } - - SafeNativeMethods.c_cholesky_factor(order, a); - } - - /// - /// Solves A*X=B for X using Cholesky factorization. - /// - /// The square, positive definite matrix A. - /// The number of rows and columns in A. - /// The B matrix. - /// The number of rows in the B matrix. - /// The number of columns in the B matrix. - /// This is equivalent to the POTRF add POTRS LAPACK routines. - public void CholeskySolve(Complex32[] a, int orderA, Complex32[] b, int rowsB, int columnsB) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using a previously factored A matrix. - /// - /// The square, positive definite matrix A. - /// The number of rows and columns in A. - /// The B matrix. - /// The number of rows in the B matrix. - /// The number of columns in the B matrix. - /// This is equivalent to the POTRS LAPACK routine. - public void CholeskySolveFactored(Complex32[] a, int orderA, Complex32[] b, int rowsB, int columnsB) - { - throw new NotImplementedException(); - } - - /// - /// Computes the QR factorization of A. - /// - /// On entry, it is the M by N A matrix to factor. On exit, - /// it is overwritten with the R matrix of the QR factorization. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// On exit, A M by M matrix that holds the Q matrix of the - /// QR factorization. - /// This is similar to the GEQRF and ORGQR LAPACK routines. - public void QRFactor(Complex32[] r, int rowsR, int columnsR, Complex32[] q) - { - throw new NotImplementedException(); - } - - /// - /// Computes the QR factorization of A. - /// - /// On entry, it is the M by N A matrix to factor. On exit, - /// it is overwritten with the R matrix of the QR factorization. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// On exit, A M by M matrix that holds the Q matrix of the - /// QR factorization. - /// The work array. The array must have a length of at least N, - /// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal - /// work size value. - /// This is similar to the GEQRF and ORGQR LAPACK routines. - public void QRFactor(Complex32[] r, int rowsR, int columnsR, Complex32[] q, Complex32[] work) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using QR factorization of A. - /// - /// On entry, it is the M by N A matrix to factor. On exit, - /// it is overwritten with the R matrix of the QR factorization. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// On exit, A M by M matrix that holds the Q matrix of the - /// QR factorization. - /// The B matrix. - /// The number of columns of B. - /// On exit, the solution matrix. - public void QRSolve(Complex32[] r, int rowsR, int columnsR, Complex32[] q, Complex32[] b, int columnsB, Complex32[] x) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using QR factorization of A. - /// - /// On entry, it is the M by N A matrix to factor. On exit, - /// it is overwritten with the R matrix of the QR factorization. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// On exit, A M by M matrix that holds the Q matrix of the - /// QR factorization. - /// The B matrix. - /// The number of columns of B. - /// On exit, the solution matrix. - /// The work array. The array must have a length of at least N, - /// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal - /// work size value. - public void QRSolve(Complex32[] r, int rowsR, int columnsR, Complex32[] q, Complex32[] b, int columnsB, Complex32[] x, Complex32[] work) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using a previously QR factored matrix. - /// - /// The Q matrix obtained by calling . - /// The R matrix obtained by calling . - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// The B matrix. - /// The number of columns of B. - /// On exit, the solution matrix. - public void QRSolveFactored(Complex32[] q, Complex32[] r, int rowsR, int columnsR, Complex32[] b, int columnsB, Complex32[] x) - { - throw new NotImplementedException(); - } - - /// - /// Computes the singular value decomposition of A. - /// - /// Compute the singular U and VT vectors or not. - /// On entry, the M by N matrix to decompose. On exit, A may be overwritten. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// The singular values of A in ascending value. - /// If is true, on exit U contains the left - /// singular vectors. - /// If is true, on exit VT contains the transposed - /// right singular vectors. - /// This is equivalent to the GESVD LAPACK routine. - public void SingularValueDecomposition(bool computeVectors, Complex32[] a, int rowsA, int columnsA, Complex32[] s, Complex32[] u, Complex32[] vt) - { - throw new NotImplementedException(); - } - - /// - /// Computes the singular value decomposition of A. - /// - /// Compute the singular U and VT vectors or not. - /// On entry, the M by N matrix to decompose. On exit, A may be overwritten. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// The singular values of A in ascending value. - /// If is true, on exit U contains the left - /// singular vectors. - /// If is true, on exit VT contains the transposed - /// right singular vectors. - /// The work array. For real matrices, the work array should be at least - /// Max(3*Min(M, N) + Max(M, N), 5*Min(M,N)). For complex matrices, 2*Min(M, N) + Max(M, N). - /// On exit, work[0] contains the optimal work size value. - /// This is equivalent to the GESVD LAPACK routine. - public void SingularValueDecomposition(bool computeVectors, Complex32[] a, int rowsA, int columnsA, Complex32[] s, Complex32[] u, Complex32[] vt, Complex32[] work) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using the singular value decomposition of A. - /// - /// On entry, the M by N matrix to decompose. On exit, A may be overwritten. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// The singular values of A in ascending value. - /// On exit U contains the left singular vectors. - /// On exit VT contains the transposed right singular vectors. - /// The B matrix. - /// The number of columns of B. - /// On exit, the solution matrix. - public void SvdSolve(Complex32[] a, int rowsA, int columnsA, Complex32[] s, Complex32[] u, Complex32[] vt, Complex32[] b, int columnsB, Complex32[] x) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using the singular value decomposition of A. - /// - /// On entry, the M by N matrix to decompose. On exit, A may be overwritten. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// The singular values of A in ascending value. - /// On exit U contains the left singular vectors. - /// On exit VT contains the transposed right singular vectors. - /// The B matrix. - /// The number of columns of B. - /// On exit, the solution matrix. - /// The work array. For real matrices, the work array should be at least - /// Max(3*Min(M, N) + Max(M, N), 5*Min(M,N)). For complex matrices, 2*Min(M, N) + Max(M, N). - /// On exit, work[0] contains the optimal work size value. - public void SvdSolve(Complex32[] a, int rowsA, int columnsA, Complex32[] s, Complex32[] u, Complex32[] vt, Complex32[] b, int columnsB, Complex32[] x, Complex32[] work) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using a previously SVD decomposed matrix. - /// - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// The s values returned by . - /// The left singular vectors returned by . - /// The right singular vectors returned by . - /// The B matrix. - /// The number of columns of B. - /// On exit, the solution matrix. - public void SvdSolveFactored(int rowsA, int columnsA, Complex32[] s, Complex32[] u, Complex32[] vt, Complex32[] b, int columnsB, Complex32[] x) - { - throw new NotImplementedException(); - } - - #endregion - } -} \ No newline at end of file diff --git a/src/Numerics/Algorithms/LinearAlgebra/Mkl/MklLinearAlgebraProvider.double.tt b/src/Numerics/Algorithms/LinearAlgebra/Mkl/MklLinearAlgebraProvider.double.tt new file mode 100644 index 00000000..69767282 --- /dev/null +++ b/src/Numerics/Algorithms/LinearAlgebra/Mkl/MklLinearAlgebraProvider.double.tt @@ -0,0 +1,10 @@ +<#@ template language="C#" debug="true" #> +<#@ output extenstion="cs" #> +<# string library = "Mkl";#> +<# string dataType = "double";#> +<# string zero = "0.0";#> +<# string one = "1.0";#> +<# string prefix = "d";#> +<# string reff = "";#> + +<#@ include file="..\NativeAlgebraProvider.include" #> \ No newline at end of file diff --git a/src/Numerics/Algorithms/LinearAlgebra/Mkl/MklLinearAlgebraProvider.float.tt b/src/Numerics/Algorithms/LinearAlgebra/Mkl/MklLinearAlgebraProvider.float.tt new file mode 100644 index 00000000..68f10401 --- /dev/null +++ b/src/Numerics/Algorithms/LinearAlgebra/Mkl/MklLinearAlgebraProvider.float.tt @@ -0,0 +1,10 @@ +<#@ template language="C#" debug="true" #> +<#@ output extenstion="cs" #> +<# string library = "Mkl";#> +<# string dataType = "float";#> +<# string zero = "0.0f";#> +<# string one = "1.0f";#> +<# string prefix = "s";#> +<# string reff = "";#> + +<#@ include file="..\NativeAlgebraProvider.include" #> \ No newline at end of file diff --git a/src/Numerics/Algorithms/LinearAlgebra/Mkl/MklLinearAlgebraProvider.tt b/src/Numerics/Algorithms/LinearAlgebra/Mkl/MklLinearAlgebraProvider.tt deleted file mode 100644 index 2f51b3d9..00000000 --- a/src/Numerics/Algorithms/LinearAlgebra/Mkl/MklLinearAlgebraProvider.tt +++ /dev/null @@ -1,4 +0,0 @@ -<#@ template language="C#" debug="true" #> -<#@ output extenstion="cs" #> -<# string library = "Mkl";#> -<#@ include file="..\NativeAlgebraProvider.include" #> \ No newline at end of file diff --git a/src/Numerics/Algorithms/LinearAlgebra/Mkl/SafeNativeMethods.cs b/src/Numerics/Algorithms/LinearAlgebra/Mkl/SafeNativeMethods.cs deleted file mode 100644 index e9c4ca63..00000000 --- a/src/Numerics/Algorithms/LinearAlgebra/Mkl/SafeNativeMethods.cs +++ /dev/null @@ -1,160 +0,0 @@ -// -// Math.NET Numerics, part of the Math.NET Project -// http://mathnet.opensourcedotnet.info -// -// Copyright (c) 2009 Math.NET -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. -// - -/* This file is automatically generated - do not modify it. - Change SafeNativeMethods.include instead. - Last generated on UTC 2010-06-09 08:17:20Z -*/ - -using System.Numerics; -using System.Runtime.InteropServices; -using System.Security; - -namespace MathNet.Numerics.Algorithms.LinearAlgebra.Mkl -{ - /// - /// P/Invoke methods to the native math libraries. - /// - [SuppressUnmanagedCodeSecurity] - internal static class SafeNativeMethods - { - /// - /// Name of the native DLL. - /// - private const string DllName = "MathNET.Numerics.MKL.dll"; - - #region BLAS - - [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] - internal static extern void s_axpy(int n, float alpha, float[] x, [In, Out] float[] y); - - [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] - internal static extern void d_axpy(int n, double alpha, double[] x, [In, Out] double[] y); - - [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] - internal static extern void c_axpy(int n, ref Complex32 alpha, Complex32[] x, [In, Out] Complex32[] y); - - [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] - internal static extern void z_axpy(int n, ref Complex alpha, Complex[] x, [In, Out] Complex[] y); - - [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] - internal static extern void s_scale(int n, float alpha, [Out] float[] x); - - [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] - internal static extern void d_scale(int n, double alpha, [Out] double[] x); - - [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] - internal static extern void c_scale(int n, ref Complex32 alpha, [In, Out] Complex32[] x); - - [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] - internal static extern void z_scale(int n, ref Complex alpha, [In, Out] Complex[] x); - - [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] - internal static extern float s_dot_product(int n, float[] x, float[] y); - - [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] - internal static extern double d_dot_product(int n, double[] x, double[] y); - - [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] - internal static extern Complex32 c_dot_product(int n, Complex32[] x, Complex32[] y); - - [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] - internal static extern Complex z_dot_product(int n, Complex[] x, Complex[] y); - - [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] - internal static extern void s_matrix_multiply(Transpose transA, Transpose transB, int m, int n, int k, float alpha, float[] x, float[] y, float beta, [In, Out]float[] c); - - [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] - internal static extern void d_matrix_multiply(Transpose transA, Transpose transB, int m, int n, int k, double alpha, double[] x, double[] y, double beta, [In, Out]double[] c); - - [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] - internal static extern void c_matrix_multiply(Transpose transA, Transpose transB, int m, int n, int k, ref Complex32 alpha, Complex32[] x, Complex32[] y, ref Complex32 beta, [In, Out]Complex32[] c); - - [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] - internal static extern void z_matrix_multiply(Transpose transA, Transpose transB, int m, int n, int k, ref Complex alpha, Complex[] x, Complex[] y, ref Complex beta, [In, Out]Complex[] c); - - #endregion BLAS - - #region LAPACK - - [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] - internal static extern void s_cholesky_factor(int n, [In, Out] float[] a); - - [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] - internal static extern void d_cholesky_factor(int n, [In, Out] double[] a); - - [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] - internal static extern void c_cholesky_factor(int n, [In, Out] Complex32[] a); - - [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] - internal static extern void z_cholesky_factor(int n, [In, Out] Complex[] a); - - #endregion LAPACK - - - #region Vector Functions - - [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] - internal static extern void s_vector_add(int n, float[] x, float[] y, [In, Out] float[] result); - - [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] - internal static extern void s_vector_subtract(int n, float[] x, float[] y, [In, Out] float[] result); - - [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] - internal static extern void s_vector_multiply(int n, float[] x, float[] y, [In, Out] float[] result); - - [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] - internal static extern void d_vector_add(int n, double[] x, double[] y, [In, Out] double[] result); - - [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] - internal static extern void d_vector_subtract(int n, double[] x, double[] y, [In, Out] double[] result); - - [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] - internal static extern void d_vector_multiply(int n, double[] x, double[] y, [In, Out] double[] result); - - [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] - internal static extern void c_vector_add(int n, Complex32[] x, Complex32[] y, [In, Out] Complex32[] result); - - [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] - internal static extern void c_vector_subtract(int n, Complex32[] x, Complex32[] y, [In, Out] Complex32[] result); - - [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] - internal static extern void c_vector_multiply(int n, Complex32[] x, Complex32[] y, [In, Out] Complex32[] result); - - [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] - internal static extern void z_vector_add(int n, Complex[] x, Complex[] y, [In, Out] Complex[] result); - - [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] - internal static extern void z_vector_subtract(int n, Complex[] x, Complex[] y, [In, Out] Complex[] result); - - [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] - internal static extern void z_vector_multiply(int n, Complex[] x, Complex[] y, [In, Out] Complex[] result); - - #endregion Vector Functions - } -} \ No newline at end of file diff --git a/src/Numerics/Algorithms/LinearAlgebra/NativeAlgebraProvider.include b/src/Numerics/Algorithms/LinearAlgebra/NativeAlgebraProvider.include index 47767bd7..d09610ef 100644 --- a/src/Numerics/Algorithms/LinearAlgebra/NativeAlgebraProvider.include +++ b/src/Numerics/Algorithms/LinearAlgebra/NativeAlgebraProvider.include @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://mathnet.opensourcedotnet.info // @@ -16,7 +16,7 @@ // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KINDC:\source\mathnet-marcus\src\Numerics\Algorithms\LinearAlgebra\NewFolder1\, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT @@ -40,14 +40,8 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.<#=library#> /// /// The managed linear algebra provider. /// - public class <#=library#>LinearAlgebraProvider : ILinearAlgebraProvider + public partial class <#=library#>LinearAlgebraProvider : ManagedLinearAlgebraProvider { -<# if( !library.Equals("Mkl") ){ #> - private readonly ILinearAlgebraProvider _managedProvider = new ManagedLinearAlgebraProvider(); -<#} #> - - #region ILinearAlgebraProvider Members - /// /// Adds a scaled vector to another: y += alpha*x. /// @@ -55,7 +49,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.<#=library#> /// The value to scale by. /// The vector to add to . /// This equivalent to the AXPY BLAS routine. - public void AddVectorToScaledVector(double[] y, double alpha, double[] x) + public override void AddVectorToScaledVector(<#=dataType#>[] y, <#=dataType#> alpha, <#=dataType#>[] x) { if (y == null) { @@ -72,12 +66,12 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.<#=library#> throw new ArgumentException(Resources.ArgumentVectorsSameLength); } - if (alpha == 0.0) + if (alpha == <#=zero#>) { return; } - SafeNativeMethods.d_axpy(y.Length, alpha, x, y); + SafeNativeMethods.<#=prefix#>_axpy(y.Length, <#=reff#>alpha, x, y); } /// @@ -86,19 +80,19 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.<#=library#> /// The scalar. /// The values to scale. /// This is equivalent to the SCAL BLAS routine. - public void ScaleArray(double alpha, double[] x) + public override void ScaleArray(<#=dataType#> alpha, <#=dataType#>[] x) { if (x == null) { throw new ArgumentNullException("x"); } - if (alpha == 1.0) + if (alpha == <#=one#>) { return; } - SafeNativeMethods.d_scale(x.Length, alpha, x); + SafeNativeMethods.<#=prefix#>_scale(x.Length, <#=reff#>alpha, x); } /// @@ -108,7 +102,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.<#=library#> /// The vector y. /// The dot product of x and y. /// This is equivalent to the DOT BLAS routine. - public double DotProduct(double[] x, double[] y) + public override <#=dataType#> DotProduct(<#=dataType#>[] x, <#=dataType#>[] y) { if (y == null) { @@ -125,9 +119,10 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.<#=library#> throw new ArgumentException(Resources.ArgumentArraysSameLength); } - return SafeNativeMethods.d_dot_product(x.Length, x, y); + return SafeNativeMethods.<#=prefix#>_dot_product(x.Length, x, y); } +<# if( library.Equals("Mkl") ){ #> /// /// Does a point wise add of two arrays z = x + y. This can be used /// to add vectors or matrices. @@ -138,7 +133,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.<#=library#> /// There is no equivalent BLAS routine, but many libraries /// provide optimized (parallel and/or vectorized) versions of this /// routine. - public void AddArrays(double[] x, double[] y, double[] result) + public override void AddArrays(<#=dataType#>[] x, <#=dataType#>[] y, <#=dataType#>[] result) { if (y == null) { @@ -159,14 +154,12 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.<#=library#> { throw new ArgumentException(Resources.ArgumentArraysSameLength); } - -<# if( library.Equals("Mkl") ){ #> - SafeNativeMethods.d_vector_add( x.Length, x, y, result ); -<#} else {#> - _managedProvider.AddArrays(x, y, result); -<#} #> + + SafeNativeMethods.<#=prefix#>_vector_add( x.Length, x, y, result ); } +<#} #> +<# if( library.Equals("Mkl") ){ #> /// /// Does a point wise subtraction of two arrays z = x - y. This can be used /// to subtract vectors or matrices. @@ -177,7 +170,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.<#=library#> /// There is no equivalent BLAS routine, but many libraries /// provide optimized (parallel and/or vectorized) versions of this /// routine. - public void SubtractArrays(double[] x, double[] y, double[] result) + public override void SubtractArrays(<#=dataType#>[] x, <#=dataType#>[] y, <#=dataType#>[] result) { if (y == null) { @@ -199,13 +192,11 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.<#=library#> throw new ArgumentException(Resources.ArgumentArraysSameLength); } -<# if( library.Equals("Mkl") ){ #> - SafeNativeMethods.d_vector_subtract( x.Length, x, y, result ); -<#} else {#> - _managedProvider.SubtractArrays(x, y, result); -<#} #> + SafeNativeMethods.<#=prefix#>_vector_subtract( x.Length, x, y, result ); } +<#} #> +<# if( library.Equals("Mkl") ){ #> /// /// Does a point wise multiplication of two arrays z = x * y. This can be used /// to multiple elements of vectors or matrices. @@ -216,7 +207,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.<#=library#> /// There is no equivalent BLAS routine, but many libraries /// provide optimized (parallel and/or vectorized) versions of this /// routine. - public void PointWiseMultiplyArrays(double[] x, double[] y, double[] result) + public override void PointWiseMultiplyArrays(<#=dataType#>[] x, <#=dataType#>[] y, <#=dataType#>[] result) { if (y == null) { @@ -238,12 +229,9 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.<#=library#> throw new ArgumentException(Resources.ArgumentArraysSameLength); } -<# if( library.Equals("Mkl") ){ #> - SafeNativeMethods.d_vector_multiply( x.Length, x, y, result ); -<#} else {#> - _managedProvider.PointWiseMultiplyArrays(x, y, result); -<#} #> + SafeNativeMethods.<#=prefix#>_vector_multiply( x.Length, x, y, result ); } +<#} #> /// /// Computes the requested of the matrix. @@ -255,7 +243,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.<#=library#> /// /// The requested of the matrix. /// - public double MatrixNorm(Norm norm, int rows, int columns, double[] matrix) + public override <#=dataType#> MatrixNorm(Norm norm, int rows, int columns, <#=dataType#>[] matrix) { throw new NotImplementedException(); } @@ -272,7 +260,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.<#=library#> /// /// The requested of the matrix. /// - public double MatrixNorm(Norm norm, int rows, int columns, double[] matrix, double[] work) + public override <#=dataType#> MatrixNorm(Norm norm, int rows, int columns, <#=dataType#>[] matrix, <#=dataType#>[] work) { throw new NotImplementedException(); } @@ -288,10 +276,10 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.<#=library#> /// The number of columns in the y matrix. /// Where to store the result of the multiplication. /// This is a simplified version of the BLAS GEMM routine with alpha - /// set to 1.0 and beta set to 0.0, and x and y are not transposed. - public void MatrixMultiply(double[] x, int xRows, int xColumns, double[] y, int yRows, int yColumns, double[] result) + /// set to <#=one#> and beta set to <#=zero#>, and x and y are not transposed. + public override void MatrixMultiply(<#=dataType#>[] x, int xRows, int xColumns, <#=dataType#>[] y, int yRows, int yColumns, <#=dataType#>[] result) { - MatrixMultiplyWithUpdate(Transpose.DontTranspose, Transpose.DontTranspose, 1.0, x, xRows, xColumns, y, yRows, yColumns, 0.0, result); + MatrixMultiplyWithUpdate(Transpose.DontTranspose, Transpose.DontTranspose, <#=one#>, x, xRows, xColumns, y, yRows, yColumns, <#=zero#>, result); } /// @@ -308,8 +296,8 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.<#=library#> /// The number of columns in the matrix. /// The value to scale the matrix. /// The c matrix. - public void MatrixMultiplyWithUpdate(Transpose transposeA, Transpose transposeB, double alpha, double[] a, - int aRows, int aColumns, double[] b, int bRows, int bColumns, double beta, double[] c) + public override void MatrixMultiplyWithUpdate(Transpose transposeA, Transpose transposeB, <#=dataType#> alpha, <#=dataType#>[] a, + int aRows, int aColumns, <#=dataType#>[] b, int bRows, int bColumns, <#=dataType#> beta, <#=dataType#>[] c) { if (a == null) { @@ -340,19 +328,19 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.<#=library#> throw new ArgumentException(Resources.ArgumentMatrixDimensions); } - SafeNativeMethods.d_matrix_multiply(transposeA, transposeB, m, n, k, alpha, a, b, beta, c); + SafeNativeMethods.<#=prefix#>_matrix_multiply(transposeA, transposeB, m, n, k, <#=reff#>alpha, a, b, <#=reff#>beta, c); } /// /// Computes the LUP factorization of A. P*A = L*U. /// /// An by matrix. The matrix is overwritten with the - /// the LU factorization on exit. The lower triangular factor L is stored in under the diagonal of (the diagonal is always 1.0 + /// the LU factorization on exit. The lower triangular factor L is stored in under the diagonal of (the diagonal is always <#=one#> /// for the L factor). The upper triangular factor U is stored on and above the diagonal of . /// The order of the square matrix . /// On exit, it contains the pivot indices. The size of the array must be . /// This is equivalent to the GETRF LAPACK routine. - public void LUFactor(double[] data, int order, int[] ipiv) + public override void LUFactor(<#=dataType#>[] data, int order, int[] ipiv) { throw new NotImplementedException(); } @@ -363,7 +351,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.<#=library#> /// The N by N matrix to invert. Contains the inverse On exit. /// The order of the square matrix . /// This is equivalent to the GETRF and GETRI LAPACK routines. - public void LUInverse(double[] a, int order) + public override void LUInverse(<#=dataType#>[] a, int order) { throw new NotImplementedException(); } @@ -375,7 +363,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.<#=library#> /// The order of the square matrix . /// The pivot indices of . /// This is equivalent to the GETRI LAPACK routine. - public void LUInverseFactored(double[] a, int order, int[] ipiv) + public override void LUInverseFactored(<#=dataType#>[] a, int order, int[] ipiv) { throw new NotImplementedException(); } @@ -389,7 +377,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.<#=library#> /// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal /// work size value. /// This is equivalent to the GETRF and GETRI LAPACK routines. - public void LUInverse(double[] a, int order, double[] work) + public override void LUInverse(<#=dataType#>[] a, int order, <#=dataType#>[] work) { throw new NotImplementedException(); } @@ -404,7 +392,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.<#=library#> /// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal /// work size value. /// This is equivalent to the GETRI LAPACK routine. - public void LUInverseFactored(double[] a, int order, int[] ipiv, double[] work) + public override void LUInverseFactored(<#=dataType#>[] a, int order, int[] ipiv, <#=dataType#>[] work) { throw new NotImplementedException(); } @@ -417,7 +405,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.<#=library#> /// The order of the square matrix . /// The B matrix. /// This is equivalent to the GETRF and GETRS LAPACK routines. - public void LUSolve(int columnsOfB, double[] a, int order, double[] b) + public override void LUSolve(int columnsOfB, <#=dataType#>[] a, int order, <#=dataType#>[] b) { throw new NotImplementedException(); } @@ -431,7 +419,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.<#=library#> /// The pivot indices of . /// The B matrix. /// This is equivalent to the GETRS LAPACK routine. - public void LUSolveFactored(int columnsOfB, double[] a, int order, int[] ipiv, double[] b) + public override void LUSolveFactored(int columnsOfB, <#=dataType#>[] a, int order, int[] ipiv, <#=dataType#>[] b) { throw new NotImplementedException(); } @@ -445,7 +433,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.<#=library#> /// The order of the square matrix . /// The B matrix. /// This is equivalent to the GETRF and GETRS LAPACK routines. - public void LUSolve(Transpose transposeA, int columnsOfB, double[] a, int order, double[] b) + public override void LUSolve(Transpose transposeA, int columnsOfB, <#=dataType#>[] a, int order, <#=dataType#>[] b) { throw new NotImplementedException(); } @@ -460,7 +448,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.<#=library#> /// The pivot indices of . /// The B matrix. /// This is equivalent to the GETRS LAPACK routine. - public void LUSolveFactored(Transpose transposeA, int columnsOfB, double[] a, int order, int[] ipiv, double[] b) + public override void LUSolveFactored(Transpose transposeA, int columnsOfB, <#=dataType#>[] a, int order, int[] ipiv, <#=dataType#>[] b) { throw new NotImplementedException(); } @@ -472,7 +460,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.<#=library#> /// the Cholesky factorization. /// The number of rows or columns in the matrix. /// This is equivalent to the POTRF LAPACK routine. - public void CholeskyFactor(double[] a, int order) + public override void CholeskyFactor(<#=dataType#>[] a, int order) { if (a == null) { @@ -484,7 +472,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.<#=library#> throw new ArgumentException(Resources.ArgumentMustBePositive, "order"); } - SafeNativeMethods.d_cholesky_factor(order, a); + SafeNativeMethods.<#=prefix#>_cholesky_factor(order, a); } /// @@ -497,7 +485,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.<#=library#> /// The number of columns in the B matrix. /// This is equivalent to the POTRF add POTRS LAPACK routines. /// - public void CholeskySolve(double[] a, int aOrder, double[] b, int bRows, int bColumns) + public override void CholeskySolve(<#=dataType#>[] a, int aOrder, <#=dataType#>[] b, int bRows, int bColumns) { throw new NotImplementedException(); } @@ -511,7 +499,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.<#=library#> /// The number of rows in the B matrix. /// The number of columns in the B matrix. /// This is equivalent to the POTRS LAPACK routine. - public void CholeskySolveFactored(double[] a, int aOrder, double[] b, int bRows, int bColumns) + public override void CholeskySolveFactored(<#=dataType#>[] a, int aOrder, <#=dataType#>[] b, int bRows, int bColumns) { throw new NotImplementedException(); } @@ -526,7 +514,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.<#=library#> /// On exit, A M by M matrix that holds the Q matrix of the /// QR factorization. /// This is similar to the GEQRF and ORGQR LAPACK routines. - public void QRFactor(double[] r, int rRows, int rColumns, double[] q) + public override void QRFactor(<#=dataType#>[] r, int rRows, int rColumns, <#=dataType#>[] q) { throw new NotImplementedException(); } @@ -544,7 +532,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.<#=library#> /// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal /// work size value. /// This is similar to the GEQRF and ORGQR LAPACK routines. - public void QRFactor(double[] r, int rRows, int rColumns, double[] q, double[] work) + public override void QRFactor(<#=dataType#>[] r, int rRows, int rColumns, <#=dataType#>[] q, <#=dataType#>[] work) { throw new NotImplementedException(); } @@ -561,7 +549,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.<#=library#> /// The B matrix. /// The number of columns of B. /// On exit, the solution matrix. - public void QRSolve(double[] r, int rRows, int rColumns, double[] q, double[] b, int bColumns, double[] x) + public override void QRSolve(<#=dataType#>[] r, int rRows, int rColumns, <#=dataType#>[] q, <#=dataType#>[] b, int bColumns, <#=dataType#>[] x) { throw new NotImplementedException(); } @@ -581,7 +569,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.<#=library#> /// The work array. The array must have a length of at least N, /// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal /// work size value. - public void QRSolve(double[] r, int rRows, int rColumns, double[] q, double[] b, int bColumns, double[] x, double[] work) + public override void QRSolve(<#=dataType#>[] r, int rRows, int rColumns, <#=dataType#>[] q, <#=dataType#>[] b, int bColumns, <#=dataType#>[] x, <#=dataType#>[] work) { throw new NotImplementedException(); } @@ -589,14 +577,14 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.<#=library#> /// /// Solves A*X=B for X using a previously QR factored matrix. /// - /// The Q matrix obtained by calling . - /// The R matrix obtained by calling . + /// The Q matrix obtained by calling . + /// The R matrix obtained by calling . /// The number of rows in the A matrix. /// The number of columns in the A matrix. /// The B matrix. /// The number of columns of B. /// On exit, the solution matrix. - public void QRSolveFactored(double[] q, double[] r, int rRows, int rColumns, double[] b, int bColumns, double[] x) + public override void QRSolveFactored(<#=dataType#>[] q, <#=dataType#>[] r, int rRows, int rColumns, <#=dataType#>[] b, int bColumns, <#=dataType#>[] x) { throw new NotImplementedException(); } @@ -614,7 +602,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.<#=library#> /// If is true, on exit VT contains the transposed /// right singular vectors. /// This is equivalent to the GESVD LAPACK routine. - public void SingularValueDecomposition(bool computeVectors, double[] a, int aRows, int aColumns, double[] s, double[] u, double[] vt) + public override void SingularValueDecomposition(bool computeVectors, <#=dataType#>[] a, int aRows, int aColumns, <#=dataType#>[] s, <#=dataType#>[] u, <#=dataType#>[] vt) { throw new NotImplementedException(); } @@ -635,7 +623,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.<#=library#> /// Max(3*Min(M, N) + Max(M, N), 5*Min(M,N)). For complex matrices, 2*Min(M, N) + Max(M, N). /// On exit, work[0] contains the optimal work size value. /// This is equivalent to the GESVD LAPACK routine. - public void SingularValueDecomposition(bool computeVectors, double[] a, int aRows, int aColumns, double[] s, double[] u, double[] vt, double[] work) + public override void SingularValueDecomposition(bool computeVectors, <#=dataType#>[] a, int aRows, int aColumns, <#=dataType#>[] s, <#=dataType#>[] u, <#=dataType#>[] vt, <#=dataType#>[] work) { throw new NotImplementedException(); } @@ -652,7 +640,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.<#=library#> /// The B matrix. /// The number of columns of B. /// On exit, the solution matrix. - public void SvdSolve(double[] a, int aRows, int aColumns, double[] s, double[] u, double[] vt, double[] b, int bColumns, double[] x) + public override void SvdSolve(<#=dataType#>[] a, int aRows, int aColumns, <#=dataType#>[] s, <#=dataType#>[] u, <#=dataType#>[] vt, <#=dataType#>[] b, int bColumns, <#=dataType#>[] x) { throw new NotImplementedException(); } @@ -672,7 +660,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.<#=library#> /// The work array. For real matrices, the work array should be at least /// Max(3*Min(M, N) + Max(M, N), 5*Min(M,N)). For complex matrices, 2*Min(M, N) + Max(M, N). /// On exit, work[0] contains the optimal work size value. - public void SvdSolve(double[] a, int aRows, int aColumns, double[] s, double[] u, double[] vt, double[] b, int bColumns, double[] x, double[] work) + public override void SvdSolve(<#=dataType#>[] a, int aRows, int aColumns, <#=dataType#>[] s, <#=dataType#>[] u, <#=dataType#>[] vt, <#=dataType#>[] b, int bColumns, <#=dataType#>[] x, <#=dataType#>[] work) { throw new NotImplementedException(); } @@ -682,1961 +670,15 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.<#=library#> /// /// The number of rows in the A matrix. /// The number of columns in the A matrix. - /// The s values returned by . - /// The left singular vectors returned by . - /// The right singular vectors returned by . + /// The s values returned by . + /// The left singular vectors returned by . + /// The right singular vectors returned by . /// The B matrix. /// The number of columns of B. /// On exit, the solution matrix. - public void SvdSolveFactored(int aRows, int aColumns, double[] s, double[] u, double[] vt, double[] b, int bColumns, double[] x) - { - throw new NotImplementedException(); - } - - #endregion - - #region ILinearAlgebraProvider Members - - /// - /// Adds a scaled vector to another: y += alpha*x. - /// - /// The vector to update. - /// The value to scale by. - /// The vector to add to . - /// This equivalent to the AXPY BLAS routine. - public void AddVectorToScaledVector(float[] y, float alpha, float[] x) - { - if (y == null) - { - throw new ArgumentNullException("y"); - } - - if (x == null) - { - throw new ArgumentNullException("x"); - } - - if (y.Length != x.Length) - { - throw new ArgumentException(Resources.ArgumentVectorsSameLength); - } - - if (alpha == 0.0f) - { - return; - } - - SafeNativeMethods.s_axpy(y.Length, alpha, x, y); - } - - /// - /// Scales an array. Can be used to scale a vector and a matrix. - /// - /// The scalar. - /// The values to scale. - /// This is equivalent to the SCAL BLAS routine. - public void ScaleArray(float alpha, float[] x) - { - if (x == null) - { - throw new ArgumentNullException("x"); - } - - if (alpha == 1.0) - { - return; - } - - SafeNativeMethods.s_scale(x.Length, alpha, x); - } - - /// - /// Computes the dot product of x and y. - /// - /// The vector x. - /// The vector y. - /// The dot product of x and y. - /// This is equivalent to the DOT BLAS routine. - public float DotProduct(float[] x, float[] y) - { - if (y == null) - { - throw new ArgumentNullException("y"); - } - - if (x == null) - { - throw new ArgumentNullException("x"); - } - - if (x.Length != y.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - - return SafeNativeMethods.s_dot_product(x.Length, x, y); - } - - /// - /// Does a point wise add of two arrays z = x + y. This can be used - /// to add vectors or matrices. - /// - /// The array x. - /// The array y. - /// The result of the addition. - /// There is no equivalent BLAS routine, but many libraries - /// provide optimized (parallel and/or vectorized) versions of this - /// routine. - public void AddArrays(float[] x, float[] y, float[] result) - { - if (y == null) - { - throw new ArgumentNullException("y"); - } - - if (x == null) - { - throw new ArgumentNullException("x"); - } - - if (x.Length != y.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - - if (x.Length != result.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - -<# if( library.Equals("Mkl") ){ #> - SafeNativeMethods.s_vector_add( x.Length, x, y, result ); -<#} else {#> - _managedProvider.AddArrays(x, y, result); -<#} #> - } - - /// - /// Does a point wise subtraction of two arrays z = x - y. This can be used - /// to subtract vectors or matrices. - /// - /// The array x. - /// The array y. - /// The result of the subtraction. - /// There is no equivalent BLAS routine, but many libraries - /// provide optimized (parallel and/or vectorized) versions of this - /// routine. - public void SubtractArrays(float[] x, float[] y, float[] result) - { - if (y == null) - { - throw new ArgumentNullException("y"); - } - - if (x == null) - { - throw new ArgumentNullException("x"); - } - - if (x.Length != y.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - - if (x.Length != result.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - -<# if( library.Equals("Mkl") ){ #> - SafeNativeMethods.s_vector_subtract( x.Length, x, y, result ); -<#} else {#> - _managedProvider.SubtractArrays(x, y, result); -<#} #> - } - - /// - /// Does a point wise multiplication of two arrays z = x * y. This can be used - /// to multiple elements of vectors or matrices. - /// - /// The array x. - /// The array y. - /// The result of the point wise multiplication. - /// There is no equivalent BLAS routine, but many libraries - /// provide optimized (parallel and/or vectorized) versions of this - /// routine. - public void PointWiseMultiplyArrays(float[] x, float[] y, float[] result) - { - if (y == null) - { - throw new ArgumentNullException("y"); - } - - if (x == null) - { - throw new ArgumentNullException("x"); - } - - if (x.Length != y.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - - if (x.Length != result.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - -<# if( library.Equals("Mkl") ){ #> - SafeNativeMethods.s_vector_multiply( x.Length, x, y, result ); -<#} else {#> - _managedProvider.PointWiseMultiplyArrays(x, y, result); -<#} #> - } - - /// - /// Computes the requested of the matrix. - /// - /// The type of norm to compute. - /// The number of rows in the matrix. - /// The number of columns in the matrix. - /// The matrix to compute the norm from. - /// - /// The requested of the matrix. - /// - public float MatrixNorm(Norm norm, int rows, int columns, float[] matrix) - { - throw new NotImplementedException(); - } - - /// - /// Computes the requested of the matrix. - /// - /// The type of norm to compute. - /// The number of rows in the matrix. - /// The number of columns in the matrix. - /// The matrix to compute the norm from. - /// The work array. Only used when - /// and needs to be have a length of at least M (number of rows of . - /// - /// The requested of the matrix. - /// - public float MatrixNorm(Norm norm, int rows, int columns, float[] matrix, float[] work) + public override void SvdSolveFactored(int aRows, int aColumns, <#=dataType#>[] s, <#=dataType#>[] u, <#=dataType#>[] vt, <#=dataType#>[] b, int bColumns, <#=dataType#>[] x) { throw new NotImplementedException(); } - - /// - /// Multiples two matrices. result = x * y - /// - /// The x matrix. - /// The number of rows in the x matrix. - /// The number of columns in the x matrix. - /// The y matrix. - /// The number of rows in the y matrix. - /// The number of columns in the y matrix. - /// Where to store the result of the multiplication. - /// This is a simplified version of the BLAS GEMM routine with alpha - /// set to 1.0 and beta set to 0.0, and x and y are not transposed. - public void MatrixMultiply(float[] x, int xRows, int xColumns, float[] y, int yRows, int yColumns, float[] result) - { - MatrixMultiplyWithUpdate(Transpose.DontTranspose, Transpose.DontTranspose, 1.0f, x, xRows, xColumns, y, yRows, yColumns, 0.0f, result); - } - - /// - /// Multiplies two matrices and updates another with the result. c = alpha*op(a)*op(b) + beta*c - /// - /// How to transpose the matrix. - /// How to transpose the matrix. - /// The value to scale matrix. - /// The a matrix. - /// The number of rows in the matrix. - /// The number of columns in the matrix. - /// The b matrix - /// The number of rows in the matrix. - /// The number of columns in the matrix. - /// The value to scale the matrix. - /// The c matrix. - public void MatrixMultiplyWithUpdate(Transpose transposeA, Transpose transposeB, float alpha, float[] a, - int aRows, int aColumns, float[] b, int bRows, int bColumns, float beta, float[] c) - { - if (a == null) - { - throw new ArgumentNullException("a"); - } - - if (b == null) - { - throw new ArgumentNullException("b"); - } - - if (c == null) - { - throw new ArgumentNullException("c"); - } - - var m = transposeA == Transpose.DontTranspose ? aRows : aColumns; - var n = transposeB == Transpose.DontTranspose ? bColumns : bRows; - var k = transposeA == Transpose.DontTranspose ? aColumns : aRows; - - if( c.Length != aRows * bColumns) - { - throw new ArgumentException(Resources.ArgumentMatrixDimensions); - } - - if (aColumns != bRows) - { - throw new ArgumentException(Resources.ArgumentMatrixDimensions); - } - - SafeNativeMethods.s_matrix_multiply(transposeA, transposeB, m, n, k, alpha, a, b, beta, c); - } - - /// - /// Computes the LUP factorization of A. P*A = L*U. - /// - /// An by matrix. The matrix is overwritten with the - /// the LU factorization on exit. The lower triangular factor L is stored in under the diagonal of (the diagonal is always 1.0 - /// for the L factor). The upper triangular factor U is stored on and above the diagonal of . - /// The order of the square matrix . - /// On exit, it contains the pivot indices. The size of the array must be . - /// This is equivalent to the GETRF LAPACK routine. - public void LUFactor(float[] data, int order, int[] ipiv) - { - throw new NotImplementedException(); - } - - /// - /// Computes the inverse of matrix using LU factorization. - /// - /// The N by N matrix to invert. Contains the inverse On exit. - /// The order of the square matrix . - /// This is equivalent to the GETRF and GETRI LAPACK routines. - public void LUInverse(float[] a, int order) - { - throw new NotImplementedException(); - } - - /// - /// Computes the inverse of a previously factored matrix. - /// - /// The LU factored N by N matrix. Contains the inverse On exit. - /// The order of the square matrix . - /// The pivot indices of . - /// This is equivalent to the GETRI LAPACK routine. - public void LUInverseFactored(float[] a, int order, int[] ipiv) - { - throw new NotImplementedException(); - } - - /// - /// Computes the inverse of matrix using LU factorization. - /// - /// The N by N matrix to invert. Contains the inverse On exit. - /// The order of the square matrix . - /// The work array. The array must have a length of at least N, - /// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal - /// work size value. - /// This is equivalent to the GETRF and GETRI LAPACK routines. - public void LUInverse(float[] a, int order, float[] work) - { - throw new NotImplementedException(); - } - - /// - /// Computes the inverse of a previously factored matrix. - /// - /// The LU factored N by N matrix. Contains the inverse On exit. - /// The order of the square matrix . - /// The pivot indices of . - /// The work array. The array must have a length of at least N, - /// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal - /// work size value. - /// This is equivalent to the GETRI LAPACK routine. - public void LUInverseFactored(float[] a, int order, int[] ipiv, float[] work) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using LU factorization. - /// - /// The number of columns of B. - /// The square matrix A. - /// The order of the square matrix . - /// The B matrix. - /// This is equivalent to the GETRF and GETRS LAPACK routines. - public void LUSolve(int columnsOfB, float[] a, int order, float[] b) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using a previously factored A matrix. - /// - /// The number of columns of B. - /// The factored A matrix. - /// The order of the square matrix . - /// The pivot indices of . - /// The B matrix. - /// This is equivalent to the GETRS LAPACK routine. - public void LUSolveFactored(int columnsOfB, float[] a, int order, int[] ipiv, float[] b) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using LU factorization. - /// - /// How to transpose the matrix. - /// The number of columns of B. - /// The square matrix A. - /// The order of the square matrix . - /// The B matrix. - /// This is equivalent to the GETRF and GETRS LAPACK routines. - public void LUSolve(Transpose transposeA, int columnsOfB, float[] a, int order, float[] b) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using a previously factored A matrix. - /// - /// How to transpose the matrix. - /// The number of columns of B. - /// The factored A matrix. - /// The order of the square matrix . - /// The pivot indices of . - /// The B matrix. - /// This is equivalent to the GETRS LAPACK routine. - public void LUSolveFactored(Transpose transposeA, int columnsOfB, float[] a, int order, int[] ipiv, float[] b) - { - throw new NotImplementedException(); - } - - /// - /// Computes the Cholesky factorization of A. - /// - /// On entry, a square, positive definite matrix. On exit, the matrix is overwritten with the - /// the Cholesky factorization. - /// The number of rows or columns in the matrix. - /// This is equivalent to the POTRF LAPACK routine. - public void CholeskyFactor(float[] a, int order) - { - if (a == null) - { - throw new ArgumentNullException("a"); - } - - if (order < 1) - { - throw new ArgumentException(Resources.ArgumentMustBePositive, "order"); - } - - SafeNativeMethods.s_cholesky_factor(order, a); - } - - /// - /// Solves A*X=B for X using Cholesky factorization. - /// - /// The square, positive definite matrix A. - /// The number of rows and columns in A. - /// The B matrix. - /// The number of rows in the B matrix. - /// The number of columns in the B matrix. - /// This is equivalent to the POTRF add POTRS LAPACK routines. - public void CholeskySolve(float[] a, int aOrder, float[] b, int bRows, int bColumns) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using a previously factored A matrix. - /// - /// The square, positive definite matrix A. - /// The number of rows and columns in A. - /// The B matrix. - /// The number of rows in the B matrix. - /// The number of columns in the B matrix. - /// This is equivalent to the POTRS LAPACK routine. - public void CholeskySolveFactored(float[] a, int aOrder, float[] b, int bRows, int bColumns) - { - throw new NotImplementedException(); - } - - /// - /// Computes the QR factorization of A. - /// - /// On entry, it is the M by N A matrix to factor. On exit, - /// it is overwritten with the R matrix of the QR factorization. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// On exit, A M by M matrix that holds the Q matrix of the - /// QR factorization. - /// This is similar to the GEQRF and ORGQR LAPACK routines. - public void QRFactor(float[] r, int rRows, int rColumns, float[] q) - { - throw new NotImplementedException(); - } - - /// - /// Computes the QR factorization of A. - /// - /// On entry, it is the M by N A matrix to factor. On exit, - /// it is overwritten with the R matrix of the QR factorization. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// On exit, A M by M matrix that holds the Q matrix of the - /// QR factorization. - /// The work array. The array must have a length of at least N, - /// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal - /// work size value. - /// This is similar to the GEQRF and ORGQR LAPACK routines. - public void QRFactor(float[] r, int rRows, int rColumns, float[] q, float[] work) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using QR factorization of A. - /// - /// On entry, it is the M by N A matrix to factor. On exit, - /// it is overwritten with the R matrix of the QR factorization. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// On exit, A M by M matrix that holds the Q matrix of the - /// QR factorization. - /// The B matrix. - /// The number of columns of B. - /// On exit, the solution matrix. - public void QRSolve(float[] r, int rRows, int rColumns, float[] q, float[] b, int bColumns, float[] x) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using QR factorization of A. - /// - /// On entry, it is the M by N A matrix to factor. On exit, - /// it is overwritten with the R matrix of the QR factorization. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// On exit, A M by M matrix that holds the Q matrix of the - /// QR factorization. - /// The B matrix. - /// The number of columns of B. - /// On exit, the solution matrix. - /// The work array. The array must have a length of at least N, - /// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal - /// work size value. - public void QRSolve(float[] r, int rRows, int rColumns, float[] q, float[] b, int bColumns, float[] x, float[] work) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using a previously QR factored matrix. - /// - /// The Q matrix obtained by calling . - /// The R matrix obtained by calling . - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// The B matrix. - /// The number of columns of B. - /// On exit, the solution matrix. - public void QRSolveFactored(float[] q, float[] r, int rRows, int rColumns, float[] b, int bColumns, float[] x) - { - throw new NotImplementedException(); - } - - /// - /// Computes the singular value decomposition of A. - /// - /// Compute the singular U and VT vectors or not. - /// On entry, the M by N matrix to decompose. On exit, A may be overwritten. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// The singular values of A in ascending value. - /// If is true, on exit U contains the left - /// singular vectors. - /// If is true, on exit VT contains the transposed - /// right singular vectors. - /// This is equivalent to the GESVD LAPACK routine. - public void SingularValueDecomposition(bool computeVectors, float[] a, int aRows, int aColumns, float[] s, float[] u, float[] vt) - { - throw new NotImplementedException(); - } - - /// - /// Computes the singular value decomposition of A. - /// - /// Compute the singular U and VT vectors or not. - /// On entry, the M by N matrix to decompose. On exit, A may be overwritten. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// The singular values of A in ascending value. - /// If is true, on exit U contains the left - /// singular vectors. - /// If is true, on exit VT contains the transposed - /// right singular vectors. - /// The work array. For real matrices, the work array should be at least - /// Max(3*Min(M, N) + Max(M, N), 5*Min(M,N)). For complex matrices, 2*Min(M, N) + Max(M, N). - /// On exit, work[0] contains the optimal work size value. - /// This is equivalent to the GESVD LAPACK routine. - public void SingularValueDecomposition(bool computeVectors, float[] a, int aRows, int aColumns, float[] s, float[] u, float[] vt, float[] work) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using the singular value decomposition of A. - /// - /// On entry, the M by N matrix to decompose. On exit, A may be overwritten. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// The singular values of A in ascending value. - /// On exit U contains the left singular vectors. - /// On exit VT contains the transposed right singular vectors. - /// The B matrix. - /// The number of columns of B. - /// On exit, the solution matrix. - public void SvdSolve(float[] a, int aRows, int aColumns, float[] s, float[] u, float[] vt, float[] b, int bColumns, float[] x) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using the singular value decomposition of A. - /// - /// On entry, the M by N matrix to decompose. On exit, A may be overwritten. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// The singular values of A in ascending value. - /// On exit U contains the left singular vectors. - /// On exit VT contains the transposed right singular vectors. - /// The B matrix. - /// The number of columns of B. - /// On exit, the solution matrix. - /// The work array. For real matrices, the work array should be at least - /// Max(3*Min(M, N) + Max(M, N), 5*Min(M,N)). For complex matrices, 2*Min(M, N) + Max(M, N). - /// On exit, work[0] contains the optimal work size value. - public void SvdSolve(float[] a, int aRows, int aColumns, float[] s, float[] u, float[] vt, float[] b, int bColumns, float[] x, float[] work) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using a previously SVD decomposed matrix. - /// - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// The s values returned by . - /// The left singular vectors returned by . - /// The right singular vectors returned by . - /// The B matrix. - /// The number of columns of B. - /// On exit, the solution matrix. - public void SvdSolveFactored(int aRows, int aColumns, float[] s, float[] u, float[] vt, float[] b, int bColumns, float[] x) - { - throw new NotImplementedException(); - } - - #endregion - - #region ILinearAlgebraProvider Members - - /// - /// Adds a scaled vector to another: y += alpha*x. - /// - /// The vector to update. - /// The value to scale by. - /// The vector to add to . - /// This equivalent to the AXPY BLAS routine. - public void AddVectorToScaledVector(Complex[] y, Complex alpha, Complex[] x) - { - if (y == null) - { - throw new ArgumentNullException("y"); - } - - if (x == null) - { - throw new ArgumentNullException("x"); - } - - if (y.Length != x.Length) - { - throw new ArgumentException(Resources.ArgumentVectorsSameLength); - } - - if (alpha.IsZero()) - { - return; - } - - SafeNativeMethods.z_axpy(y.Length, ref alpha, x, y); - } - - /// - /// Scales an array. Can be used to scale a vector and a matrix. - /// - /// The scalar. - /// The values to scale. - /// This is equivalent to the SCAL BLAS routine. - public void ScaleArray(Complex alpha, Complex[] x) - { - if (x == null) - { - throw new ArgumentNullException("x"); - } - - if (alpha.IsOne()) - { - return; - } - - SafeNativeMethods.z_scale(x.Length, ref alpha, x); - } - - /// - /// Computes the dot product of x and y. - /// - /// The vector x. - /// The vector y. - /// The dot product of x and y. - /// This is equivalent to the DOT BLAS routine. - public Complex DotProduct(Complex[] x, Complex[] y) - { - if (y == null) - { - throw new ArgumentNullException("y"); - } - - if (x == null) - { - throw new ArgumentNullException("x"); - } - - if (x.Length != y.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - - return SafeNativeMethods.z_dot_product(x.Length, x, y); - } - - /// - /// Does a point wise add of two arrays z = x + y. This can be used - /// to add vectors or matrices. - /// - /// The array x. - /// The array y. - /// The result of the addition. - /// There is no equivalent BLAS routine, but many libraries - /// provide optimized (parallel and/or vectorized) versions of this - /// routine. - public void AddArrays(Complex[] x, Complex[] y, Complex[] result) - { - if (y == null) - { - throw new ArgumentNullException("y"); - } - - if (x == null) - { - throw new ArgumentNullException("x"); - } - - if (x.Length != y.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - - if (x.Length != result.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - -<# if( library.Equals("Mkl") ){ #> - SafeNativeMethods.z_vector_add( x.Length, x, y, result ); -<#} else {#> - _managedProvider.AddArrays(x, y, result); -<#} #> - } - - /// - /// Does a point wise subtraction of two arrays z = x - y. This can be used - /// to subtract vectors or matrices. - /// - /// The array x. - /// The array y. - /// The result of the subtraction. - /// There is no equivalent BLAS routine, but many libraries - /// provide optimized (parallel and/or vectorized) versions of this - /// routine. - public void SubtractArrays(Complex[] x, Complex[] y, Complex[] result) - { - if (y == null) - { - throw new ArgumentNullException("y"); - } - - if (x == null) - { - throw new ArgumentNullException("x"); - } - - if (x.Length != y.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - - if (x.Length != result.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - -<# if( library.Equals("Mkl") ){ #> - SafeNativeMethods.z_vector_subtract( x.Length, x, y, result ); -<#} else {#> - _managedProvider.SubtractArrays(x, y, result); -<#} #> - } - - /// - /// Does a point wise multiplication of two arrays z = x * y. This can be used - /// to multiple elements of vectors or matrices. - /// - /// The array x. - /// The array y. - /// The result of the point wise multiplication. - /// There is no equivalent BLAS routine, but many libraries - /// provide optimized (parallel and/or vectorized) versions of this - /// routine. - public void PointWiseMultiplyArrays(Complex[] x, Complex[] y, Complex[] result) - { - if (y == null) - { - throw new ArgumentNullException("y"); - } - - if (x == null) - { - throw new ArgumentNullException("x"); - } - - if (x.Length != y.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - - if (x.Length != result.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - -<# if( library.Equals("Mkl") ){ #> - SafeNativeMethods.z_vector_multiply( x.Length, x, y, result ); -<#} else {#> - _managedProvider.PointWiseMultiplyArrays(x, y, result); -<#} #> - } - - /// - /// Computes the requested of the matrix. - /// - /// The type of norm to compute. - /// The number of rows in the matrix. - /// The number of columns in the matrix. - /// The matrix to compute the norm from. - /// - /// The requested of the matrix. - /// - public Complex MatrixNorm(Norm norm, int rows, int columns, Complex[] matrix) - { - throw new NotImplementedException(); - } - - /// - /// Computes the requested of the matrix. - /// - /// The type of norm to compute. - /// The number of rows in the matrix. - /// The number of columns in the matrix. - /// The matrix to compute the norm from. - /// The work array. Only used when - /// and needs to be have a length of at least M (number of rows of . - /// - /// The requested of the matrix. - /// - public Complex MatrixNorm(Norm norm, int rows, int columns, Complex[] matrix, Complex[] work) - { - throw new NotImplementedException(); - } - - /// - /// Multiples two matrices. result = x * y - /// - /// The x matrix. - /// The number of rows in the x matrix. - /// The number of columns in the x matrix. - /// The y matrix. - /// The number of rows in the y matrix. - /// The number of columns in the y matrix. - /// Where to store the result of the multiplication. - /// This is a simplified version of the BLAS GEMM routine with alpha - /// set to 1.0 and beta set to 0.0, and x and y are not transposed. - public void MatrixMultiply(Complex[] x, int xRows, int xColumns, Complex[] y, int yRows, int yColumns, Complex[] result) - { - MatrixMultiplyWithUpdate(Transpose.DontTranspose, Transpose.DontTranspose, Complex.One, x, xRows, xColumns, y, yRows, yColumns, Complex.Zero, result); - } - - /// - /// Multiplies two matrices and updates another with the result. c = alpha*op(a)*op(b) + beta*c - /// - /// How to transpose the matrix. - /// How to transpose the matrix. - /// The value to scale matrix. - /// The a matrix. - /// The number of rows in the matrix. - /// The number of columns in the matrix. - /// The b matrix - /// The number of rows in the matrix. - /// The number of columns in the matrix. - /// The value to scale the matrix. - /// The c matrix. - public void MatrixMultiplyWithUpdate(Transpose transposeA, Transpose transposeB, Complex alpha, Complex[] a, - int aRows, int aColumns, Complex[] b, int bRows, int bColumns, Complex beta, Complex[] c) - { - if (a == null) - { - throw new ArgumentNullException("a"); - } - - if (b == null) - { - throw new ArgumentNullException("b"); - } - - if (c == null) - { - throw new ArgumentNullException("c"); - } - - var m = transposeA == Transpose.DontTranspose ? aRows : aColumns; - var n = transposeB == Transpose.DontTranspose ? bColumns : bRows; - var k = transposeA == Transpose.DontTranspose ? aColumns : aRows; - - if( c.Length != aRows * bColumns) - { - throw new ArgumentException(Resources.ArgumentMatrixDimensions); - } - - if (aColumns != bRows) - { - throw new ArgumentException(Resources.ArgumentMatrixDimensions); - } - - SafeNativeMethods.z_matrix_multiply(transposeA, transposeB, m, n, k, ref alpha, a, b, ref beta, c); - } - - /// - /// Computes the LUP factorization of A. P*A = L*U. - /// - /// An by matrix. The matrix is overwritten with the - /// the LU factorization on exit. The lower triangular factor L is stored in under the diagonal of (the diagonal is always 1.0 - /// for the L factor). The upper triangular factor U is stored on and above the diagonal of . - /// The order of the square matrix . - /// On exit, it contains the pivot indices. The size of the array must be . - /// This is equivalent to the GETRF LAPACK routine. - public void LUFactor(Complex[] data, int order, int[] ipiv) - { - throw new NotImplementedException(); - } - - /// - /// Computes the inverse of matrix using LU factorization. - /// - /// The N by N matrix to invert. Contains the inverse On exit. - /// The order of the square matrix . - /// This is equivalent to the GETRF and GETRI LAPACK routines. - public void LUInverse(Complex[] a, int order) - { - throw new NotImplementedException(); - } - - /// - /// Computes the inverse of a previously factored matrix. - /// - /// The LU factored N by N matrix. Contains the inverse On exit. - /// The order of the square matrix . - /// The pivot indices of . - /// This is equivalent to the GETRI LAPACK routine. - public void LUInverseFactored(Complex[] a, int order, int[] ipiv) - { - throw new NotImplementedException(); - } - - /// - /// Computes the inverse of matrix using LU factorization. - /// - /// The N by N matrix to invert. Contains the inverse On exit. - /// The order of the square matrix . - /// The work array. The array must have a length of at least N, - /// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal - /// work size value. - /// This is equivalent to the GETRF and GETRI LAPACK routines. - public void LUInverse(Complex[] a, int order, Complex[] work) - { - throw new NotImplementedException(); - } - - /// - /// Computes the inverse of a previously factored matrix. - /// - /// The LU factored N by N matrix. Contains the inverse On exit. - /// The order of the square matrix . - /// The pivot indices of . - /// The work array. The array must have a length of at least N, - /// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal - /// work size value. - /// This is equivalent to the GETRI LAPACK routine. - public void LUInverseFactored(Complex[] a, int order, int[] ipiv, Complex[] work) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using LU factorization. - /// - /// The number of columns of B. - /// The square matrix A. - /// The order of the square matrix . - /// The B matrix. - /// This is equivalent to the GETRF and GETRS LAPACK routines. - public void LUSolve(int columnsOfB, Complex[] a, int order, Complex[] b) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using a previously factored A matrix. - /// - /// The number of columns of B. - /// The factored A matrix. - /// The order of the square matrix . - /// The pivot indices of . - /// The B matrix. - /// This is equivalent to the GETRS LAPACK routine. - public void LUSolveFactored(int columnsOfB, Complex[] a, int order, int[] ipiv, Complex[] b) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using LU factorization. - /// - /// How to transpose the matrix. - /// The number of columns of B. - /// The square matrix A. - /// The order of the square matrix . - /// The B matrix. - /// This is equivalent to the GETRF and GETRS LAPACK routines. - public void LUSolve(Transpose transposeA, int columnsOfB, Complex[] a, int order, Complex[] b) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using a previously factored A matrix. - /// - /// How to transpose the matrix. - /// The number of columns of B. - /// The factored A matrix. - /// The order of the square matrix . - /// The pivot indices of . - /// The B matrix. - /// This is equivalent to the GETRS LAPACK routine. - public void LUSolveFactored(Transpose transposeA, int columnsOfB, Complex[] a, int order, int[] ipiv, Complex[] b) - { - throw new NotImplementedException(); - } - - /// - /// Computes the Cholesky factorization of A. - /// - /// On entry, a square, positive definite matrix. On exit, the matrix is overwritten with the - /// the Cholesky factorization. - /// The number of rows or columns in the matrix. - /// This is equivalent to the POTRF LAPACK routine. - public void CholeskyFactor(Complex[] a, int order) - { - if (a == null) - { - throw new ArgumentNullException("a"); - } - - if (order < 1) - { - throw new ArgumentException(Resources.ArgumentMustBePositive, "order"); - } - - SafeNativeMethods.z_cholesky_factor(order, a); - } - - /// - /// Solves A*X=B for X using Cholesky factorization. - /// - /// The square, positive definite matrix A. - /// The number of rows and columns in A. - /// The B matrix. - /// The number of rows in the B matrix. - /// The number of columns in the B matrix. - /// This is equivalent to the POTRF add POTRS LAPACK routines. - public void CholeskySolve(Complex[] a, int aOrder, Complex[] b, int bRows, int bColumns) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using a previously factored A matrix. - /// - /// The square, positive definite matrix A. - /// The number of rows and columns in A. - /// The B matrix. - /// The number of rows in the B matrix. - /// The number of columns in the B matrix. - /// This is equivalent to the POTRS LAPACK routine. - public void CholeskySolveFactored(Complex[] a, int aOrder, Complex[] b, int bRows, int bColumns) - { - throw new NotImplementedException(); - } - - /// - /// Computes the QR factorization of A. - /// - /// On entry, it is the M by N A matrix to factor. On exit, - /// it is overwritten with the R matrix of the QR factorization. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// On exit, A M by M matrix that holds the Q matrix of the - /// QR factorization. - /// This is similar to the GEQRF and ORGQR LAPACK routines. - public void QRFactor(Complex[] r, int rRows, int rColumns, Complex[] q) - { - throw new NotImplementedException(); - } - - /// - /// Computes the QR factorization of A. - /// - /// On entry, it is the M by N A matrix to factor. On exit, - /// it is overwritten with the R matrix of the QR factorization. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// On exit, A M by M matrix that holds the Q matrix of the - /// QR factorization. - /// The work array. The array must have a length of at least N, - /// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal - /// work size value. - /// This is similar to the GEQRF and ORGQR LAPACK routines. - public void QRFactor(Complex[] r, int rRows, int rColumns, Complex[] q, Complex[] work) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using QR factorization of A. - /// - /// On entry, it is the M by N A matrix to factor. On exit, - /// it is overwritten with the R matrix of the QR factorization. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// On exit, A M by M matrix that holds the Q matrix of the - /// QR factorization. - /// The B matrix. - /// The number of columns of B. - /// On exit, the solution matrix. - public void QRSolve(Complex[] r, int rRows, int rColumns, Complex[] q, Complex[] b, int bColumns, Complex[] x) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using QR factorization of A. - /// - /// On entry, it is the M by N A matrix to factor. On exit, - /// it is overwritten with the R matrix of the QR factorization. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// On exit, A M by M matrix that holds the Q matrix of the - /// QR factorization. - /// The B matrix. - /// The number of columns of B. - /// On exit, the solution matrix. - /// The work array. The array must have a length of at least N, - /// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal - /// work size value. - public void QRSolve(Complex[] r, int rRows, int rColumns, Complex[] q, Complex[] b, int bColumns, Complex[] x, Complex[] work) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using a previously QR factored matrix. - /// - /// The Q matrix obtained by calling . - /// The R matrix obtained by calling . - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// The B matrix. - /// The number of columns of B. - /// On exit, the solution matrix. - public void QRSolveFactored(Complex[] q, Complex[] r, int rRows, int rColumns, Complex[] b, int bColumns, Complex[] x) - { - throw new NotImplementedException(); - } - - /// - /// Computes the singular value decomposition of A. - /// - /// Compute the singular U and VT vectors or not. - /// On entry, the M by N matrix to decompose. On exit, A may be overwritten. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// The singular values of A in ascending value. - /// If is true, on exit U contains the left - /// singular vectors. - /// If is true, on exit VT contains the transposed - /// right singular vectors. - /// This is equivalent to the GESVD LAPACK routine. - public void SingularValueDecomposition(bool computeVectors, Complex[] a, int aRows, int aColumns, Complex[] s, Complex[] u, Complex[] vt) - { - throw new NotImplementedException(); - } - - /// - /// Computes the singular value decomposition of A. - /// - /// Compute the singular U and VT vectors or not. - /// On entry, the M by N matrix to decompose. On exit, A may be overwritten. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// The singular values of A in ascending value. - /// If is true, on exit U contains the left - /// singular vectors. - /// If is true, on exit VT contains the transposed - /// right singular vectors. - /// The work array. For real matrices, the work array should be at least - /// Max(3*Min(M, N) + Max(M, N), 5*Min(M,N)). For complex matrices, 2*Min(M, N) + Max(M, N). - /// On exit, work[0] contains the optimal work size value. - /// This is equivalent to the GESVD LAPACK routine. - public void SingularValueDecomposition(bool computeVectors, Complex[] a, int aRows, int aColumns, Complex[] s, Complex[] u, Complex[] vt, Complex[] work) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using the singular value decomposition of A. - /// - /// On entry, the M by N matrix to decompose. On exit, A may be overwritten. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// The singular values of A in ascending value. - /// On exit U contains the left singular vectors. - /// On exit VT contains the transposed right singular vectors. - /// The B matrix. - /// The number of columns of B. - /// On exit, the solution matrix. - public void SvdSolve(Complex[] a, int aRows, int aColumns, Complex[] s, Complex[] u, Complex[] vt, Complex[] b, int bColumns, Complex[] x) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using the singular value decomposition of A. - /// - /// On entry, the M by N matrix to decompose. On exit, A may be overwritten. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// The singular values of A in ascending value. - /// On exit U contains the left singular vectors. - /// On exit VT contains the transposed right singular vectors. - /// The B matrix. - /// The number of columns of B. - /// On exit, the solution matrix. - /// The work array. For real matrices, the work array should be at least - /// Max(3*Min(M, N) + Max(M, N), 5*Min(M,N)). For complex matrices, 2*Min(M, N) + Max(M, N). - /// On exit, work[0] contains the optimal work size value. - public void SvdSolve(Complex[] a, int aRows, int aColumns, Complex[] s, Complex[] u, Complex[] vt, Complex[] b, int bColumns, Complex[] x, Complex[] work) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using a previously SVD decomposed matrix. - /// - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// The s values returned by . - /// The left singular vectors returned by . - /// The right singular vectors returned by . - /// The B matrix. - /// The number of columns of B. - /// On exit, the solution matrix. - public void SvdSolveFactored(int aRows, int aColumns, Complex[] s, Complex[] u, Complex[] vt, Complex[] b, int bColumns, Complex[] x) - { - throw new NotImplementedException(); - } - - #endregion - - #region ILinearAlgebraProvider Members - - /// - /// Adds a scaled vector to another: y += alpha*x. - /// - /// The vector to update. - /// The value to scale by. - /// The vector to add to . - /// This equivalent to the AXPY BLAS routine. - public void AddVectorToScaledVector(Complex32[] y, Complex32 alpha, Complex32[] x) - { - if (y == null) - { - throw new ArgumentNullException("y"); - } - - if (x == null) - { - throw new ArgumentNullException("x"); - } - - if (y.Length != x.Length) - { - throw new ArgumentException(Resources.ArgumentVectorsSameLength); - } - - if (alpha.IsZero()) - { - return; - } - - SafeNativeMethods.c_axpy(y.Length, ref alpha, x, y); - } - - /// - /// Scales an array. Can be used to scale a vector and a matrix. - /// - /// The scalar. - /// The values to scale. - /// This is equivalent to the SCAL BLAS routine. - public void ScaleArray(Complex32 alpha, Complex32[] x) - { - if (x == null) - { - throw new ArgumentNullException("x"); - } - - if (alpha.IsOne()) - { - return; - } - - SafeNativeMethods.c_scale(x.Length, ref alpha, x); - } - - /// - /// Computes the dot product of x and y. - /// - /// The vector x. - /// The vector y. - /// The dot product of x and y. - /// This is equivalent to the DOT BLAS routine. - public Complex32 DotProduct(Complex32[] x, Complex32[] y) - { - if (y == null) - { - throw new ArgumentNullException("y"); - } - - if (x == null) - { - throw new ArgumentNullException("x"); - } - - if (x.Length != y.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - - return SafeNativeMethods.c_dot_product(x.Length, x, y); - } - - /// - /// Does a point wise add of two arrays z = x + y. This can be used - /// to add vectors or matrices. - /// - /// The array x. - /// The array y. - /// The result of the addition. - /// There is no equivalent BLAS routine, but many libraries - /// provide optimized (parallel and/or vectorized) versions of this - /// routine. - public void AddArrays(Complex32[] x, Complex32[] y, Complex32[] result) - { - if (y == null) - { - throw new ArgumentNullException("y"); - } - - if (x == null) - { - throw new ArgumentNullException("x"); - } - - if (x.Length != y.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - - if (x.Length != result.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - -<# if( library.Equals("Mkl") ){ #> - SafeNativeMethods.c_vector_add( x.Length, x, y, result ); -<#} else {#> - _managedProvider.AddArrays(x, y, result); -<#} #> - } - - /// - /// Does a point wise subtraction of two arrays z = x - y. This can be used - /// to subtract vectors or matrices. - /// - /// The array x. - /// The array y. - /// The result of the subtraction. - /// There is no equivalent BLAS routine, but many libraries - /// provide optimized (parallel and/or vectorized) versions of this - /// routine. - public void SubtractArrays(Complex32[] x, Complex32[] y, Complex32[] result) - { - if (y == null) - { - throw new ArgumentNullException("y"); - } - - if (x == null) - { - throw new ArgumentNullException("x"); - } - - if (x.Length != y.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - - if (x.Length != result.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - -<# if( library.Equals("Mkl") ){ #> - SafeNativeMethods.c_vector_subtract( x.Length, x, y, result ); -<#} else {#> - _managedProvider.SubtractArrays(x, y, result); -<#} #> - } - - /// - /// Does a point wise multiplication of two arrays z = x * y. This can be used - /// to multiple elements of vectors or matrices. - /// - /// The array x. - /// The array y. - /// The result of the point wise multiplication. - /// There is no equivalent BLAS routine, but many libraries - /// provide optimized (parallel and/or vectorized) versions of this - /// routine. - public void PointWiseMultiplyArrays(Complex32[] x, Complex32[] y, Complex32[] result) - { - if (y == null) - { - throw new ArgumentNullException("y"); - } - - if (x == null) - { - throw new ArgumentNullException("x"); - } - - if (x.Length != y.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - - if (x.Length != result.Length) - { - throw new ArgumentException(Resources.ArgumentArraysSameLength); - } - -<# if( library.Equals("Mkl") ){ #> - SafeNativeMethods.c_vector_multiply( x.Length, x, y, result ); -<#} else {#> - _managedProvider.PointWiseMultiplyArrays(x, y, result); -<#} #> - } - - /// - /// Computes the requested of the matrix. - /// - /// The type of norm to compute. - /// The number of rows. - /// The number of columns. - /// The matrix to compute the norm from. - /// - /// The requested of the matrix. - /// - public Complex32 MatrixNorm(Norm norm, int rows, int columns, Complex32[] matrix) - { - throw new NotImplementedException(); - } - - /// - /// Computes the requested of the matrix. - /// - /// The type of norm to compute. - /// The number of rows. - /// The number of columns. - /// The matrix to compute the norm from. - /// The work array. Only used when - /// and needs to be have a length of at least M (number of rows of . - /// - /// The requested of the matrix. - /// - public Complex32 MatrixNorm(Norm norm, int rows, int columns, Complex32[] matrix, Complex32[] work) - { - throw new NotImplementedException(); - } - - /// - /// Multiples two matrices. result = x * y - /// - /// The x matrix. - /// The number of rows in the x matrix. - /// The number of columns in the x matrix. - /// The y matrix. - /// The number of rows in the y matrix. - /// The number of columns in the y matrix. - /// Where to store the result of the multiplication. - /// This is a simplified version of the BLAS GEMM routine with alpha - /// set to 1.0 and beta set to 0.0, and x and y are not transposed. - public void MatrixMultiply(Complex32[] x, int xRows, int xColumns, Complex32[] y, int yRows, int yColumns, Complex32[] result) - { - MatrixMultiplyWithUpdate(Transpose.DontTranspose, Transpose.DontTranspose, Complex32.One, x, xRows, xColumns, y, yRows, yColumns, Complex32.Zero, result); - } - - /// - /// Multiplies two matrices and updates another with the result. c = alpha*op(a)*op(b) + beta*c - /// - /// How to transpose the matrix. - /// How to transpose the matrix. - /// The value to scale matrix. - /// The a matrix. - /// The number of rows in the matrix. - /// The number of columns in the matrix. - /// The b matrix - /// The number of rows in the matrix. - /// The number of columns in the matrix. - /// The value to scale the matrix. - /// The c matrix. - public void MatrixMultiplyWithUpdate(Transpose transposeA, Transpose transposeB, Complex32 alpha, Complex32[] a, - int aRows, int aColumns, Complex32[] b, int bRows, int bColumns, Complex32 beta, Complex32[] c) - { - if (a == null) - { - throw new ArgumentNullException("a"); - } - - if (b == null) - { - throw new ArgumentNullException("b"); - } - - if (c == null) - { - throw new ArgumentNullException("c"); - } - - var m = transposeA == Transpose.DontTranspose ? aRows : aColumns; - var n = transposeB == Transpose.DontTranspose ? bColumns : bRows; - var k = transposeA == Transpose.DontTranspose ? aColumns : aRows; - - if( c.Length != aRows * bColumns) - { - throw new ArgumentException(Resources.ArgumentMatrixDimensions); - } - - if (aColumns != bRows) - { - throw new ArgumentException(Resources.ArgumentMatrixDimensions); - } - - SafeNativeMethods.c_matrix_multiply(transposeA, transposeB, m, n, k, ref alpha, a, b, ref beta, c); - } - - /// - /// Computes the LUP factorization of A. P*A = L*U. - /// - /// An by matrix. The matrix is overwritten with the - /// the LU factorization on exit. The lower triangular factor L is stored in under the diagonal of (the diagonal is always 1.0 - /// for the L factor). The upper triangular factor U is stored on and above the diagonal of . - /// The order of the square matrix . - /// On exit, it contains the pivot indices. The size of the array must be . - /// This is equivalent to the GETRF LAPACK routine. - public void LUFactor(Complex32[] data, int order, int[] ipiv) - { - throw new NotImplementedException(); - } - - /// - /// Computes the inverse of matrix using LU factorization. - /// - /// The N by N matrix to invert. Contains the inverse On exit. - /// The order of the square matrix . - /// This is equivalent to the GETRF and GETRI LAPACK routines. - public void LUInverse(Complex32[] a, int order) - { - throw new NotImplementedException(); - } - - /// - /// Computes the inverse of a previously factored matrix. - /// - /// The LU factored N by N matrix. Contains the inverse On exit. - /// The order of the square matrix . - /// The pivot indices of . - /// This is equivalent to the GETRI LAPACK routine. - public void LUInverseFactored(Complex32[] a, int order, int[] ipiv) - { - throw new NotImplementedException(); - } - - /// - /// Computes the inverse of matrix using LU factorization. - /// - /// The N by N matrix to invert. Contains the inverse On exit. - /// The order of the square matrix . - /// The work array. The array must have a length of at least N, - /// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal - /// work size value. - /// This is equivalent to the GETRF and GETRI LAPACK routines. - public void LUInverse(Complex32[] a, int order, Complex32[] work) - { - throw new NotImplementedException(); - } - - /// - /// Computes the inverse of a previously factored matrix. - /// - /// The LU factored N by N matrix. Contains the inverse On exit. - /// The order of the square matrix . - /// The pivot indices of . - /// The work array. The array must have a length of at least N, - /// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal - /// work size value. - /// This is equivalent to the GETRI LAPACK routine. - public void LUInverseFactored(Complex32[] a, int order, int[] ipiv, Complex32[] work) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using LU factorization. - /// - /// The number of columns of B. - /// The square matrix A. - /// The order of the square matrix . - /// The B matrix. - /// This is equivalent to the GETRF and GETRS LAPACK routines. - public void LUSolve(int columnsOfB, Complex32[] a, int order, Complex32[] b) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using a previously factored A matrix. - /// - /// The number of columns of B. - /// The factored A matrix. - /// The order of the square matrix . - /// The pivot indices of . - /// The B matrix. - /// This is equivalent to the GETRS LAPACK routine. - public void LUSolveFactored(int columnsOfB, Complex32[] a, int order, int[] ipiv, Complex32[] b) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using LU factorization. - /// - /// How to transpose the matrix. - /// The number of columns of B. - /// The square matrix A. - /// The order of the square matrix . - /// The B matrix. - /// This is equivalent to the GETRF and GETRS LAPACK routines. - public void LUSolve(Transpose transposeA, int columnsOfB, Complex32[] a, int order, Complex32[] b) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using a previously factored A matrix. - /// - /// How to transpose the matrix. - /// The number of columns of B. - /// The factored A matrix. - /// The order of the square matrix . - /// The pivot indices of . - /// The B matrix. - /// This is equivalent to the GETRS LAPACK routine. - public void LUSolveFactored(Transpose transposeA, int columnsOfB, Complex32[] a, int order, int[] ipiv, Complex32[] b) - { - throw new NotImplementedException(); - } - - /// - /// Computes the Cholesky factorization of A. - /// - /// On entry, a square, positive definite matrix. On exit, the matrix is overwritten with the - /// the Cholesky factorization. - /// The number of rows or columns in the matrix. - /// This is equivalent to the POTRF LAPACK routine. - public void CholeskyFactor(Complex32[] a, int order) - { - if (a == null) - { - throw new ArgumentNullException("a"); - } - - if (order < 1) - { - throw new ArgumentException(Resources.ArgumentMustBePositive, "order"); - } - - SafeNativeMethods.c_cholesky_factor(order, a); - } - - /// - /// Solves A*X=B for X using Cholesky factorization. - /// - /// The square, positive definite matrix A. - /// The number of rows and columns in A. - /// The B matrix. - /// The number of rows in the B matrix. - /// The number of columns in the B matrix. - /// This is equivalent to the POTRF add POTRS LAPACK routines. - public void CholeskySolve(Complex32[] a, int aOrder, Complex32[] b, int bRows, int bColumns) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using a previously factored A matrix. - /// - /// The square, positive definite matrix A. - /// The number of rows and columns in A. - /// The B matrix. - /// The number of rows in the B matrix. - /// The number of columns in the B matrix. - /// This is equivalent to the POTRS LAPACK routine. - public void CholeskySolveFactored(Complex32[] a, int aOrder, Complex32[] b, int bRows, int bColumns) - { - throw new NotImplementedException(); - } - - /// - /// Computes the QR factorization of A. - /// - /// On entry, it is the M by N A matrix to factor. On exit, - /// it is overwritten with the R matrix of the QR factorization. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// On exit, A M by M matrix that holds the Q matrix of the - /// QR factorization. - /// This is similar to the GEQRF and ORGQR LAPACK routines. - public void QRFactor(Complex32[] r, int rRows, int rColumns, Complex32[] q) - { - throw new NotImplementedException(); - } - - /// - /// Computes the QR factorization of A. - /// - /// On entry, it is the M by N A matrix to factor. On exit, - /// it is overwritten with the R matrix of the QR factorization. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// On exit, A M by M matrix that holds the Q matrix of the - /// QR factorization. - /// The work array. The array must have a length of at least N, - /// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal - /// work size value. - /// This is similar to the GEQRF and ORGQR LAPACK routines. - public void QRFactor(Complex32[] r, int rRows, int rColumns, Complex32[] q, Complex32[] work) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using QR factorization of A. - /// - /// On entry, it is the M by N A matrix to factor. On exit, - /// it is overwritten with the R matrix of the QR factorization. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// On exit, A M by M matrix that holds the Q matrix of the - /// QR factorization. - /// The B matrix. - /// The number of columns of B. - /// On exit, the solution matrix. - public void QRSolve(Complex32[] r, int rRows, int rColumns, Complex32[] q, Complex32[] b, int bColumns, Complex32[] x) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using QR factorization of A. - /// - /// On entry, it is the M by N A matrix to factor. On exit, - /// it is overwritten with the R matrix of the QR factorization. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// On exit, A M by M matrix that holds the Q matrix of the - /// QR factorization. - /// The B matrix. - /// The number of columns of B. - /// On exit, the solution matrix. - /// The work array. The array must have a length of at least N, - /// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal - /// work size value. - public void QRSolve(Complex32[] r, int rRows, int rColumns, Complex32[] q, Complex32[] b, int bColumns, Complex32[] x, Complex32[] work) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using a previously QR factored matrix. - /// - /// The Q matrix obtained by calling . - /// The R matrix obtained by calling . - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// The B matrix. - /// The number of columns of B. - /// On exit, the solution matrix. - public void QRSolveFactored(Complex32[] q, Complex32[] r, int rRows, int rColumns, Complex32[] b, int bColumns, Complex32[] x) - { - throw new NotImplementedException(); - } - - /// - /// Computes the singular value decomposition of A. - /// - /// Compute the singular U and VT vectors or not. - /// On entry, the M by N matrix to decompose. On exit, A may be overwritten. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// The singular values of A in ascending value. - /// If is true, on exit U contains the left - /// singular vectors. - /// If is true, on exit VT contains the transposed - /// right singular vectors. - /// This is equivalent to the GESVD LAPACK routine. - public void SingularValueDecomposition(bool computeVectors, Complex32[] a, int aRows, int aColumns, Complex32[] s, Complex32[] u, Complex32[] vt) - { - throw new NotImplementedException(); - } - - /// - /// Computes the singular value decomposition of A. - /// - /// Compute the singular U and VT vectors or not. - /// On entry, the M by N matrix to decompose. On exit, A may be overwritten. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// The singular values of A in ascending value. - /// If is true, on exit U contains the left - /// singular vectors. - /// If is true, on exit VT contains the transposed - /// right singular vectors. - /// The work array. For real matrices, the work array should be at least - /// Max(3*Min(M, N) + Max(M, N), 5*Min(M,N)). For complex matrices, 2*Min(M, N) + Max(M, N). - /// On exit, work[0] contains the optimal work size value. - /// This is equivalent to the GESVD LAPACK routine. - public void SingularValueDecomposition(bool computeVectors, Complex32[] a, int aRows, int aColumns, Complex32[] s, Complex32[] u, Complex32[] vt, Complex32[] work) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using the singular value decomposition of A. - /// - /// On entry, the M by N matrix to decompose. On exit, A may be overwritten. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// The singular values of A in ascending value. - /// On exit U contains the left singular vectors. - /// On exit VT contains the transposed right singular vectors. - /// The B matrix. - /// The number of columns of B. - /// On exit, the solution matrix. - public void SvdSolve(Complex32[] a, int aRows, int aColumns, Complex32[] s, Complex32[] u, Complex32[] vt, Complex32[] b, int bColumns, Complex32[] x) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using the singular value decomposition of A. - /// - /// On entry, the M by N matrix to decompose. On exit, A may be overwritten. - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// The singular values of A in ascending value. - /// On exit U contains the left singular vectors. - /// On exit VT contains the transposed right singular vectors. - /// The B matrix. - /// The number of columns of B. - /// On exit, the solution matrix. - /// The work array. For real matrices, the work array should be at least - /// Max(3*Min(M, N) + Max(M, N), 5*Min(M,N)). For complex matrices, 2*Min(M, N) + Max(M, N). - /// On exit, work[0] contains the optimal work size value. - public void SvdSolve(Complex32[] a, int aRows, int aColumns, Complex32[] s, Complex32[] u, Complex32[] vt, Complex32[] b, int bColumns, Complex32[] x, Complex32[] work) - { - throw new NotImplementedException(); - } - - /// - /// Solves A*X=B for X using a previously SVD decomposed matrix. - /// - /// The number of rows in the A matrix. - /// The number of columns in the A matrix. - /// The s values returned by . - /// The left singular vectors returned by . - /// The right singular vectors returned by . - /// The B matrix. - /// The number of columns of B. - /// On exit, the solution matrix. - public void SvdSolveFactored(int aRows, int aColumns, Complex32[] s, Complex32[] u, Complex32[] vt, Complex32[] b, int bColumns, Complex32[] x) - { - throw new NotImplementedException(); - } - - #endregion } } \ No newline at end of file diff --git a/src/Numerics/Numerics.csproj b/src/Numerics/Numerics.csproj index de6ffaeb..8564b599 100644 --- a/src/Numerics/Numerics.csproj +++ b/src/Numerics/Numerics.csproj @@ -70,6 +70,26 @@ + + TextTemplatingFileGenerator + MklLinearAlgebraProvider.Complex32.cs + + + TextTemplatingFileGenerator + MklLinearAlgebraProvider.Complex.cs + + + TextTemplatingFileGenerator + MklLinearAlgebraProvider.float.cs + + + TextTemplatingFileGenerator + MklLinearAlgebraProvider.double.cs + + + TextTemplatingFileGenerator + SafeNativeMethods.cs + @@ -77,6 +97,31 @@ + + MklLinearAlgebraProvider.Complex32.tt + True + True + + + MklLinearAlgebraProvider.Complex.tt + True + True + + + MklLinearAlgebraProvider.float.tt + True + True + + + True + True + MklLinearAlgebraProvider.double.tt + + + True + True + SafeNativeMethods.tt +