GEOSX
BlasLapackLA.hpp
Go to the documentation of this file.
1 /*
2  * ------------------------------------------------------------------------------------------------------------
3  * SPDX-License-Identifier: LGPL-2.1-only
4  *
5  * Copyright (c) 2018-2020 Lawrence Livermore National Security LLC
6  * Copyright (c) 2018-2020 The Board of Trustees of the Leland Stanford Junior University
7  * Copyright (c) 2018-2020 Total, S.A
8  * Copyright (c) 2019- GEOSX Contributors
9  * All rights reserved
10  *
11  * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details.
12  * ------------------------------------------------------------------------------------------------------------
13  */
14 
18 #ifndef GEOSX_LINEARALGEBRA_INTERFACES_BLASLAPACKLA_HPP_
19 #define GEOSX_LINEARALGEBRA_INTERFACES_BLASLAPACKLA_HPP_
20 
21 #include <complex>
22 #include "common/DataTypes.hpp"
23 #include "common/Logger.hpp"
24 #include "linearAlgebra/common.hpp"
25 
26 namespace geosx
27 {
28 
35 {
37  template< typename T >
39 
41  template< typename T >
43 
45  template< typename T >
47 
53  {
54  UNIFORM_01 = 1,
55  UNIFORM_m1p1 = 2,
56  NORMAL_01 = 3
57  };
58 
65  static real64 vectorNorm1( Vec< real64 const > const & X );
66 
73  static real64 vectorNorm2( Vec< real64 const > const & X );
74 
81  static real64 vectorNormInf( Vec< real64 const > const & X );
82 
98 
102  static real64 determinant( MatColMajor< real64 const > const & A );
103 
117 
122 
135  static real64 matrixNorm1( MatRowMajor< real64 const > const & A );
136 
140  static real64 matrixNorm1( MatColMajor< real64 const > const & A );
141 
155 
160 
175  static void vectorVectorAdd( Vec< real64 const > const & X,
176  Vec< real64 > const & Y,
177  real64 const alpha = 1. );
178 
193  static void matrixMatrixAdd( MatRowMajor< real64 const > const & A,
194  MatRowMajor< real64 > const & B,
195  real64 const alpha = 1. );
196 
200  static void matrixMatrixAdd( MatColMajor< real64 const > const & A,
201  MatColMajor< real64 > const & B,
202  real64 const alpha = 1. );
203 
211  static void vectorScale( real64 const alpha,
212  Vec< real64 > const & X );
213 
221  static void matrixScale( real64 const alpha,
222  MatRowMajor< real64 > const & A );
223 
227  static void matrixScale( real64 const alpha,
228  MatColMajor< real64 > const & A );
229 
237  static real64 vectorDot( Vec< real64 const > const & X,
238  Vec< real64 const > const & Y );
239 
255  static void matrixVectorMultiply( MatRowMajor< real64 const > const & A,
256  Vec< real64 const > const & X,
257  Vec< real64 > const & Y,
258  real64 const alpha = 1.0,
259  real64 const beta = 0.0 );
260 
278  static void matrixTVectorMultiply( MatRowMajor< real64 const > const & A,
279  Vec< real64 const > const & X,
280  Vec< real64 > const & Y,
281  real64 const alpha = 1.0,
282  real64 const beta = 0.0 );
283 
301  static void matrixMatrixMultiply( MatRowMajor< real64 const > const & A,
302  MatRowMajor< real64 const > const & B,
303  MatRowMajor< real64 > const & C,
304  real64 const alpha = 1.0,
305  real64 const beta = 0.0 );
306 
326  static void matrixTMatrixMultiply( MatRowMajor< real64 const > const & A,
327  MatRowMajor< real64 const > const & B,
328  MatRowMajor< real64 > const & C,
329  real64 const alpha = 1.0,
330  real64 const beta = 0.0 );
331 
351  static void matrixMatrixTMultiply( MatRowMajor< real64 const > const & A,
352  MatRowMajor< real64 const > const & B,
353  MatRowMajor< real64 > const & C,
354  real64 const alpha = 1.0,
355  real64 const beta = 0.0 );
356 
377  MatRowMajor< real64 const > const & B,
378  MatRowMajor< real64 > const & C,
379  real64 const alpha = 1.0,
380  real64 const beta = 0.0 );
381 
405  static void matrixInverse( MatRowMajor< real64 const > const & A,
406  MatRowMajor< real64 > const & Ainv,
407  real64 & detA );
408 
412  static void matrixInverse( MatColMajor< real64 const > const & A,
413  MatColMajor< real64 > const & Ainv,
414  real64 & detA );
415 
437  static void matrixInverse( MatRowMajor< real64 const > const & A,
438  MatRowMajor< real64 > const & Ainv );
439 
443  static void matrixInverse( MatColMajor< real64 const > const & A,
444  MatColMajor< real64 > const & Ainv );
445 
457  static void vectorCopy( Vec< real64 const > const & X,
458  Vec< real64 > const & Y );
459 
471  static void matrixCopy( MatRowMajor< real64 const > const & A,
472  MatRowMajor< real64 > const & B );
473 
477  static void matrixCopy( MatColMajor< real64 const > const & A,
478  MatColMajor< real64 > const & B );
479 
486  static void setRandomNumberGeneratorSeed( arraySlice1d< int const > const & seed );
487 
493  static void getRandomNumberGeneratorSeed( arraySlice1d< int > const & seed );
494 
505  static void vectorRand( Vec< real64 > const & X,
507 
518  static void matrixRand( MatRowMajor< real64 > const & A,
520 
524  static void matrixRand( MatColMajor< real64 > const & A,
526 
527 
543  static void matrixSVD( MatRowMajor< real64 const > const & A,
544  MatRowMajor< real64 > const & U,
545  Vec< real64 > const & S,
546  MatRowMajor< real64 > const & VT );
547 
551  static void matrixSVD( MatColMajor< real64 const > const & A,
552  MatColMajor< real64 > const & U,
553  Vec< real64 > const & S,
554  MatColMajor< real64 > const & VT );
555 
566  static void matrixEigenvalues( MatRowMajor< real64 const > const & A,
567  Vec< std::complex< real64 > > const & lambda );
568 
572  static void matrixEigenvalues( MatColMajor< real64 const > const & A,
573  Vec< std::complex< real64 > > const & lambda );
574 
575 };
576 
577 }
578 
579 #endif /*GEOSX_LINEARALGEBRA_BLASLAPACKLA_HPP_*/
static void vectorCopy(Vec< real64 const > const &X, Vec< real64 > const &Y)
Vector copy; Y = X.
static real64 vectorNormInf(Vec< real64 const > const &X)
Returns the infinity-norm of the vector.
static void matrixCopy(MatRowMajor< real64 const > const &A, MatRowMajor< real64 > const &B)
Matrix copy; B = A.
static void matrixMatrixAdd(MatRowMajor< real64 const > const &A, MatRowMajor< real64 > const &B, real64 const alpha=1.)
Matrix-Matrix sum; B = alpha*A + B.
static void matrixScale(real64 const alpha, MatRowMajor< real64 > const &A)
In-place scalar-matrix product; A = alpha*A.
static real64 vectorDot(Vec< real64 const > const &X, Vec< real64 const > const &Y)
Returns the dot product of two vectors.
This class serves to provide a sliced multidimensional interface to the family of LvArray classes...
Definition: ArraySlice.hpp:89
static void matrixTMatrixTMultiply(MatRowMajor< real64 const > const &A, MatRowMajor< real64 const > const &B, MatRowMajor< real64 > const &C, real64 const alpha=1.0, real64 const beta=0.0)
transpose(Matrix)-transpose(Matrix) product; C = alpha*transpose(A)*transpose(B) + beta*C...
static void matrixMatrixMultiply(MatRowMajor< real64 const > const &A, MatRowMajor< real64 const > const &B, MatRowMajor< real64 > const &C, real64 const alpha=1.0, real64 const beta=0.0)
Matrix-Matrix product; C = alpha*A*B + beta*C.
This class contains a collection of BLAS and LAPACK linear algebra operations for GEOSX array1d and a...
static void matrixSVD(MatRowMajor< real64 const > const &A, MatRowMajor< real64 > const &U, Vec< real64 > const &S, MatRowMajor< real64 > const &VT)
Computes the singular value decomposition of A.
static real64 matrixNormInf(MatRowMajor< real64 const > const &A)
Returns the infinity norm of the matrix.
static void matrixTVectorMultiply(MatRowMajor< real64 const > const &A, Vec< real64 const > const &X, Vec< real64 > const &Y, real64 const alpha=1.0, real64 const beta=0.0)
transpose(Matrix)-Vector product; Y = alpha*transpose(A)*X + beta*Y.
static void matrixInverse(MatRowMajor< real64 const > const &A, MatRowMajor< real64 > const &Ainv, real64 &detA)
Computes the inverse matrix; Ainv = inverse(A).
double real64
64-bit floating point type.
Definition: DataTypes.hpp:136
static real64 matrixNormFrobenius(MatRowMajor< real64 const > const &A)
Returns the Frobenius norm of the matrix.
static void vectorScale(real64 const alpha, Vec< real64 > const &X)
In-place scalar-vector product; X = alpha*X.
static void vectorVectorAdd(Vec< real64 const > const &X, Vec< real64 > const &Y, real64 const alpha=1.)
Vector-Vector sum; Y = alpha*X + Y.
static void matrixVectorMultiply(MatRowMajor< real64 const > const &A, Vec< real64 const > const &X, Vec< real64 > const &Y, real64 const alpha=1.0, real64 const beta=0.0)
Matrix-Vector product; Y = alpha*A*X + beta*Y.
static void vectorRand(Vec< real64 > const &X, RandomNumberDistribution const &idist=RandomNumberDistribution::UNIFORM_01)
Sets vector entries to random real numbers.
static void setRandomNumberGeneratorSeed(arraySlice1d< int const > const &seed)
Set the random number generator seed.
static void matrixMatrixTMultiply(MatRowMajor< real64 const > const &A, MatRowMajor< real64 const > const &B, MatRowMajor< real64 > const &C, real64 const alpha=1.0, real64 const beta=0.0)
Matrix-transpose(Matrix) product; C = alpha*A*transpose(B) + beta*C.
static real64 matrixNorm1(MatRowMajor< real64 const > const &A)
Returns the one norm of the matrix.
static void matrixTMatrixMultiply(MatRowMajor< real64 const > const &A, MatRowMajor< real64 const > const &B, MatRowMajor< real64 > const &C, real64 const alpha=1.0, real64 const beta=0.0)
transpose(Matrix)-Matrix product; C = alpha*transpose(A)*B + beta*C.
RandomNumberDistribution
This enum class specifies the type of distribution for generating random real numbers.
std::int32_t integer
Signed integer type.
Definition: DataTypes.hpp:122
static void matrixEigenvalues(MatRowMajor< real64 const > const &A, Vec< std::complex< real64 > > const &lambda)
Computes the eigenvalues of A.
static real64 vectorNorm1(Vec< real64 const > const &X)
Returns the 1-norm of the vector.
static void matrixRand(MatRowMajor< real64 > const &A, RandomNumberDistribution const &idist=RandomNumberDistribution::UNIFORM_01)
Sets matrix entries to random real numbers.
static real64 vectorNorm2(Vec< real64 const > const &X)
Returns the two norm of the vector.
static void getRandomNumberGeneratorSeed(arraySlice1d< int > const &seed)
Get the random number generator seed.
static real64 determinant(MatRowMajor< real64 const > const &A)
Returns the determinant of a square matrix.