/// <summary>Initializes a new instance of the <see cref="BlasNativeWrapper" /> class. /// </summary> /// <param name="name">The name of the Library.</param> /// <param name="level1">The implementation of level 1 BLAS functions.</param> /// <param name="level2">The implementation of level 2 BLAS functions.</param> /// <param name="level3">The implementation of level 3 BLAS functions.</param> protected BlasNativeWrapper(IdentifierString name, ILevel1BLAS level1, ILevel2BLAS level2, ILevel3BLAS level3) { m_Name = name ?? throw new ArgumentNullException(nameof(name)); m_Level1 = level1 ?? throw new ArgumentNullException(nameof(level1)); m_Level2 = level2 ?? throw new ArgumentNullException(nameof(level2)); m_Level3 = level3 ?? throw new ArgumentNullException(nameof(level3)); }
/// <summary>Initializes the <see cref="BLAS"/> class. /// </summary> /// <remarks>This constructor takes into account the Managed Extensibility Framework (MEF) with respect to <see cref="LowLevelMathConfiguration"/>.</remarks> static BLAS() { ILibrary blas = null; try { blas = LowLevelMathConfiguration.BLAS.CreateFromConfigurationFile(); if (blas == null) { blas = LowLevelMathConfiguration.BLAS.Libraries.BuildIn; Logger.Stream.LogError(LowLevelMathConfigurationResources.LogFileMessageConfigFileUseDefaultImplementation, "BLAS"); } } catch (Exception e) { /* thrown of Exceptions in static constructors should be avoided: */ Logger.Stream.LogError(e, LowLevelMathConfigurationResources.LogFileMessageCorruptConfigFile); blas = LowLevelMathConfiguration.BLAS.Libraries.BuildIn; Logger.Stream.LogError(String.Format(LowLevelMathConfigurationResources.LogFileMessageConfigFileUseDefaultImplementation, "BLAS")); } Level1 = blas.Level1; Level2 = blas.Level2; Level3 = blas.Level3; }
/// <summary>Initializes a new instance of the <see cref="BlasNativeWrapper" /> class. /// </summary> public BlasNativeWrapper() { m_Name = new IdentifierString("BLAS"); m_Level1 = new Level1BLAS(); m_Level2 = new Level2BLAS(); m_Level3 = new Level3BLAS(); }
/// <summary>Initializes a new instance of the <see cref="CBlasNativeWrapper" /> class. /// </summary> public CBlasNativeWrapper() { m_Name = new IdentifierString("CBLAS"); m_Level1 = new Level1CBLAS(); m_Level2 = new Level2CBLAS(); m_Level3 = new Level3CBLAS(); }
/// <summary>Initializes a new instance of the <see cref="CBlasNativeWrapper" /> class. /// </summary> /// <param name="name">The name of the Library.</param> /// <param name="level1">The implementation of level 1 BLAS functions.</param> /// <param name="level2">The implementation of level 2 BLAS functions.</param> /// <param name="level3">The implementation of level 3 BLAS functions.</param> protected CBlasNativeWrapper(IdentifierString name, ILevel1BLAS level1, ILevel2BLAS level2, ILevel3BLAS level3) { if (name == null) { throw new ArgumentNullException("name"); } m_Name = name; if (level1 == null) { throw new ArgumentNullException("level1"); } m_Level1 = level1; if (level2 == null) { throw new ArgumentNullException("level2"); } m_Level2 = level2; if (level3 == null) { throw new ArgumentNullException("level3"); } m_Level3 = level3; }
/// <summary>Performs a rank-1 update of a Hermitian matrix, i.e. A := \alpha * x * conj(x^t) + A. /// </summary> /// <param name="level2">The BLAS level 2 implementation.</param> /// <param name="n">The order of matrix A.</param> /// <param name="alpha">The scalar \alpha.</param> /// <param name="x">The vector x with at least 1 + (<paramref name="n"/>-1) * |<paramref name="incX"/>| elements.</param> /// <param name="a">The Hermitian matrix A with dimension (<paramref name="n"/>, <paramref name="n"/>).</param> /// <param name="triangularMatrixType">A value whether matrix A is in its upper or lower triangular representation.</param> /// <param name="incX">The increment for the elements of <paramref name="x"/>.</param> public static void zher(this ILevel2BLAS level2, int n, double alpha, Complex[] x, Complex[] a, BLAS.TriangularMatrixType triangularMatrixType = BLAS.TriangularMatrixType.UpperTriangularMatrix, int incX = 1) { level2.zher(n, alpha, x, a, n, triangularMatrixType, incX); }
/// <summary>Computes a matrix-vector product for a general matrix, i.e. y = \alpha * op(A)*x + \beta*y, where \op(A) = A or \op(A)=A^t. /// </summary> /// <param name="level2">The BLAS level 2 implementation.</param> /// <param name="m">The number of rows of matrix A.</param> /// <param name="n">The number of columns of matrix A.</param> /// <param name="alpha">The scalar \alpha.</param> /// <param name="a">The matrix A of dimension (<paramref name="m"/>, <paramref name="n"/>) supplied column-by-column.</param> /// <param name="x">The vector x with at least 1 + (<paramref name="n"/>-1) * |<paramref name="incX"/>| elements if 'op(A)=A'; 1 + (<paramref name="m"/>-1) * |<paramref name="incY"/>| elements otherwise.</param> /// <param name="beta">The scalar \beta.</param> /// <param name="y">The vector y with at least 1 + (<paramref name="m"/>-1) * |<paramref name="incY"/>| elements if 'op(A)=A'; 1 + (<paramref name="n"/>-1) * | <paramref name="incX"/>| otherwise (input/output).</param> /// <param name="transpose">A value indicating whether 'op(A)=A' or 'op(A)=A^t'.</param> /// <param name="incX">The increment for the elements of <paramref name="x"/>.</param> /// <param name="incY">The increment for the elements of <paramref name="y"/>.</param> public static void dgemv(this ILevel2BLAS level2, int m, int n, double alpha, double[] a, double[] x, double beta, double[] y, BLAS.MatrixTransposeState transpose = BLAS.MatrixTransposeState.NoTranspose, int incX = 1, int incY = 1) { level2.dgemv(m, n, alpha, a, x, beta, y, m, transpose, incX, incY); }
/// <summary>Performs a rank-1 update of a general matrix, i.e. A := \alpha * x * y^t + A. /// </summary> /// <param name="level2">The BLAS level 2 implementation.</param> /// <param name="m">The number of rows of matrix A.</param> /// <param name="n">The number of columns of matrix A.</param> /// <param name="alpha">The scalar \alpha.</param> /// <param name="x">The vector x with at least 1 + (<paramref name="m"/>-1) * |<paramref name="incX"/>| elements.</param> /// <param name="y">The vector y with at least 1 + (<paramref name="n"/>-1) * |<paramref name="incY"/>| elements.</param> /// <param name="a">The matrix A of dimension (<paramref name="m"/>, <paramref name="n"/>) supplied column-by-column (input/output).</param> /// <param name="incX">The increment for the elements of <paramref name="x"/>.</param> /// <param name="incY">The increment for the elements of <paramref name="y"/>.</param> public static void dger(this ILevel2BLAS level2, int m, int n, double alpha, double[] x, double[] y, double[] a, int incX = 1, int incY = 1) { level2.dger(m, n, alpha, x, y, a, m, incX, incY); }
/// <summary>Performs a rank-2 update of a Hermitian matrix, i.e. A := \alpha * x * conjg(y^t) + conjg(\alpha) * y * conjg(x^t) + A. /// </summary> /// <param name="level2">The BLAS level 2 implementation.</param> /// <param name="n">The order of matrix A.</param> /// <param name="alpha">The scalar \alpha.</param> /// <param name="x">The vector x with at least 1 + (<paramref name="n"/>-1) * |<paramref name="incX"/>| elements.</param> /// <param name="y">The vector y with at least 1 + (<paramref name="n"/>-1) * |<paramref name="incY"/>| elements.</param> /// <param name="a">The Hermitian matrix A with dimension (<paramref name="n"/>, <paramref name="n"/>).</param> /// <param name="triangularMatrixType">A value whether matrix A is in its upper or lower triangular representation.</param> /// <param name="incX">The increment for the elements of <paramref name="x"/>.</param> /// <param name="incY">The increment for the elements of <paramref name="y"/>.</param> public static void zher2(this ILevel2BLAS level2, int n, Complex alpha, Complex[] x, Complex[] y, Complex[] a, BLAS.TriangularMatrixType triangularMatrixType = BLAS.TriangularMatrixType.UpperTriangularMatrix, int incX = 1, int incY = 1) { level2.zher2(n, alpha, x, y, a, n, triangularMatrixType, incX, incY); }
/// <summary>Solves a system of linear equations whose coefficients are in a triangular matrix, i.e. op(A) * x = b, where op(A) = A, op(A) = A ^t or op(A) = A^h. /// </summary> /// <param name="level2">The BLAS level 2 implementation.</param> /// <param name="n">The order of matrix A.</param> /// <param name="a">The triangular matrix A with dimension (<paramref name="n"/>, <paramref name="n"/>).</param> /// <param name="x">The vector x with at least 1 + (<paramref name="n"/> - 1) * | <paramref name="incX"/> | elements.</param> /// <param name="triangularMatrixType">A value whether matrix A is in its upper or lower triangular representation.</param> /// <param name="isUnitTriangular">A value indicating whether the matrix A is unit triangular.</param> /// <param name="transpose">A value indicating whether 'op(A)=A', 'op(A)=A^t' or 'op(A)=A^h'.</param> /// <param name="incX">The increment for the elements of <paramref name="x"/>.</param> public static void ztrsv(this ILevel2BLAS level2, int n, Complex[] a, Complex[] x, BLAS.TriangularMatrixType triangularMatrixType = BLAS.TriangularMatrixType.UpperTriangularMatrix, bool isUnitTriangular = true, BLAS.MatrixTransposeState transpose = BLAS.MatrixTransposeState.NoTranspose, int incX = 1) { level2.ztrsv(n, a, x, n, triangularMatrixType, isUnitTriangular, transpose, incX); }
/// <summary>Computes a matrix-vector product using a Hermitian band matrix, i.e. y := \alpha * A * x + \beta * y. /// </summary> /// <param name="level2">The BLAS level 2 implementation.</param> /// <param name="n">The order of matrix A.</param> /// <param name="k">The number of super-diagonals.</param> /// <param name="alpha">The scalar \alpha.</param> /// <param name="a">The matrix Hermitian band matrix A with dimension (1 + <paramref name="k"/>, <paramref name="n"/>).</param> /// <param name="x">The vector x with at least 1 + (<paramref name="n"/>-1) * |<paramref name="incX"/>| elements.</param> /// <param name="beta">The scalar \beta.</param> /// <param name="y">The vector y with at least 1 + (<paramref name="n"/>-1) * |<paramref name="incY"/>| elements (input/output).</param> /// <param name="triangularMatrixType">A value whether matrix A is in its upper or lower triangular representation.</param> /// <param name="incX">The increment for the elements of <paramref name="x"/>.</param> /// <param name="incY">The increment for the elements of <paramref name="y"/>.</param> public static void zhbmv(this ILevel2BLAS level2, int n, int k, Complex alpha, Complex[] a, Complex[] x, Complex beta, Complex[] y, BLAS.TriangularMatrixType triangularMatrixType = BLAS.TriangularMatrixType.UpperTriangularMatrix, int incX = 1, int incY = 1) { level2.zhbmv(n, k, alpha, a, x, beta, y, 1 + k, triangularMatrixType, incX, incY); }
/// <summary>Computes a matrix-vector product using a symmetric band matrix, i.e. y:= \alpha * A * x + \beta * y. /// </summary> /// <param name="level2">The BLAS level 2 implementation.</param> /// <param name="n">The order of matrix A.</param> /// <param name="k">The number of super-diagonals of matrix A.</param> /// <param name="alpha">The scalar \alpha.</param> /// <param name="a">The matrix A of dimension (1+<paramref name="k"/>, <paramref name="n"/>) supplied column-by-column.</param> /// <param name="x">The vector x with at least 1 + (<paramref name="n"/> - 1) * | <paramref name="incX"/> | elements.</param> /// <param name="beta">The scalar \beta.</param> /// <param name="y">The vector y with at least 1 + (<paramref name="n"/> - 1) * | <paramref name="incY"/> | elements (input/output).</param> /// <param name="triangularMatrixType">A value whether matrix A is in its upper or lower triangular representation.</param> /// <param name="incX">The increment for the elements of <paramref name="x"/>.</param> /// <param name="incY">The increment for the elements of <paramref name="y"/>.</param> public static void dsbmv(this ILevel2BLAS level2, int n, int k, double alpha, double[] a, double[] x, double beta, double[] y, BLAS.TriangularMatrixType triangularMatrixType = BLAS.TriangularMatrixType.UpperTriangularMatrix, int incX = 1, int incY = 1) { level2.dsbmv(n, k, alpha, a, x, beta, y, 1 + k, triangularMatrixType, incX, incY); }
/// <summary>Performs a rank-1 update (unconjugated) of a general matrix., i.e. A := \alpha * x * y^t + A. /// </summary> /// <param name="level2">The BLAS level 2 implementation.</param> /// <param name="m">The number of rows of matrix A.</param> /// <param name="n">The number of columns of matrix A.</param> /// <param name="alpha">The scalar \alpha.</param> /// <param name="x">The vector x with at least 1 + (<paramref name="m"/>-1) * |<paramref name="incX"/>| elements.</param> /// <param name="y">The vector y with at least 1 + (<paramref name="n"/>-1) * |<paramref name="incY"/>| elements.</param> /// <param name="a">The matrix A with dimension (<paramref name="m"/>, <paramref name="n"/>) supplied column-by-column.</param> /// <param name="incX">The increment for the elements of <paramref name="x"/>.</param> /// <param name="incY">The increment for the elements of <paramref name="y"/>.</param> public static void zgeru(this ILevel2BLAS level2, int m, int n, Complex alpha, Complex[] x, Complex[] y, Complex[] a, int incX = 1, int incY = 1) { level2.zgeru(m, n, alpha, x, y, a, m, incX, incY); }
/// <summary>Computes a matrix-vector product for a general matrix, i.e. y = \alpha * op(A)*x + \beta*y, where op(A) = A, op(A) = A^t or op(A) = A^h. /// </summary> /// <param name="level2">The BLAS level 2 implementation.</param> /// <param name="m">The number of rows of matrix A.</param> /// <param name="n">The number of columns of matrix A.</param> /// <param name="alpha">The scalar \alpha.</param> /// <param name="a">The matrix A of dimension (<paramref name="m"/>, <paramref name="n"/>) supplied column-by-column.</param> /// <param name="x">The vector x with at least 1 + (<paramref name="n"/>-1) * |<paramref name="incX"/>| elements if 'op(A)=A'; 1 + (<paramref name="m"/>-1) * |<paramref name="incY"/>| elements otherwise.</param> /// <param name="beta">The scalar \beta.</param> /// <param name="y">The vector y with at least 1 + (<paramref name="m"/>-1) * |<paramref name="incY"/>| elements if 'op(A)=A'; 1 + (<paramref name="n"/>-1) * | <paramref name="incX"/>| otherwise (input/output).</param> /// <param name="transpose">A value indicating whether 'op(A)=A' or 'op(A)=A^t'.</param> /// <param name="incX">The increment for the elements of <paramref name="x"/>.</param> /// <param name="incY">The increment for the elements of <paramref name="y"/>.</param> public static void zgemv(this ILevel2BLAS level2, int m, int n, Complex alpha, Complex[] a, Complex[] x, Complex beta, Complex[] y, BLAS.MatrixTransposeState transpose = BLAS.MatrixTransposeState.NoTranspose, int incX = 1, int incY = 1) { level2.zgemv(m, n, alpha, a, x, beta, y, m, transpose, incX, incY); }
/// <summary>Solves a system of linear equations whose coefficients are in a triangular matrix, i.e. op(A) * x = b, where op(A) = A or op(A) = A^t. /// </summary> /// <param name="level2">The BLAS level 2 implementation.</param> /// <param name="n">The order of matrix A.</param> /// <param name="a">The triangular matrix A with dimension (<paramref name="n"/>, <paramref name="n"/>).</param> /// <param name="x">The vector b (input), x (output) with at least 1 + (<paramref name="n"/> - 1) * | <paramref name="incX"/> | elements (input/output).</param> /// <param name="triangularMatrixType">A value whether matrix A is in its upper or lower triangular representation.</param> /// <param name="isUnitTriangular">A value indicating whether the matrix A is unit triangular.</param> /// <param name="transpose">A value indicating whether op(A) = A or op(A) = A^t.</param> /// <param name="incX">The increment for the elements of <paramref name="x"/>.</param> public static void dtrsv(this ILevel2BLAS level2, int n, double[] a, double[] x, BLAS.TriangularMatrixType triangularMatrixType, bool isUnitTriangular = true, BLAS.MatrixTransposeState transpose = BLAS.MatrixTransposeState.NoTranspose, int incX = 1) { level2.dtrsv(n, a, x, n, triangularMatrixType, isUnitTriangular, transpose, incX); }
/// <summary>Computes a matrix-vector product using a triangular band matrix, i.e. x := op(A) * x, where op(A) = A or op(A) = A^t. /// </summary> /// <param name="level2">The BLAS level 2 implementation.</param> /// <param name="n">The order of matrix A.</param> /// <param name="k">The number of super-diagonales of A if the matrix A is provided in its upper triangular representation; the number of sub-diagonals otherwise.</param> /// <param name="a">The triangular band matrix with dimension ( 1 + <paramref name="k"/>, <paramref name="n"/>).</param> /// <param name="x">The vector x with at least 1 + (<paramref name="n"/> - 1) * | <paramref name="incX"/> | elements.</param> /// <param name="triangularMatrixType">A value whether matrix A is in its upper or lower triangular representation.</param> /// <param name="isUnitTriangular">A value indicating whether the matrix A is unit triangular.</param> /// <param name="transpose">A value indicating whether 'op(A)=A' or 'op(A)=A^t'.</param> /// <param name="incX">The increment for the elements of <paramref name="x"/>.</param> public static void dtbmv(this ILevel2BLAS level2, int n, int k, double[] a, double[] x, BLAS.TriangularMatrixType triangularMatrixType = BLAS.TriangularMatrixType.UpperTriangularMatrix, bool isUnitTriangular = true, BLAS.MatrixTransposeState transpose = BLAS.MatrixTransposeState.NoTranspose, int incX = 1) { level2.dtbmv(n, k, a, x, 1 + k, triangularMatrixType, isUnitTriangular, transpose, incX); }
/// <summary>Performs a rank-2 update of a symmetric matrix, i.e. A := \alpha * x * y^t + \alpha * y * x^t + A. /// </summary> /// <param name="level2">The BLAS level 2 implementation.</param> /// <param name="n">The order of matrix A.</param> /// <param name="alpha">The scalar \alpha.</param> /// <param name="x">The vector x with at least 1 + (<paramref name="n"/> - 1) * | <paramref name="incX"/> | elements.</param> /// <param name="y">The vector y with at least 1 + (<paramref name="n"/> - 1) * | <paramref name="incY"/> | elements.</param> /// <param name="a">The symmetric matrix A of dimension (<paramref name="n"/>, <paramref name="n"/>) supplied column-by-column (input/output).</param> /// <param name="triangularMatrixType">A value whether matrix A is in its upper or lower triangular representation.</param> /// <param name="incX">The increment for the elements of <paramref name="x"/>.</param> /// <param name="incY">The increment for the elements of <paramref name="y"/>.</param> public static void dsyr2(this ILevel2BLAS level2, int n, double alpha, double[] x, double[] y, double[] a, BLAS.TriangularMatrixType triangularMatrixType = BLAS.TriangularMatrixType.UpperTriangularMatrix, int incX = 1, int incY = 1) { level2.dsyr2(n, alpha, x, y, a, n, triangularMatrixType, incX, incY); }