/usr/include/libwildmagic/Wm5LinearSystem.h is in libwildmagic-dev 5.13-1+b2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | // Geometric Tools, LLC
// Copyright (c) 1998-2014
// Distributed under the Boost Software License, Version 1.0.
// http://www.boost.org/LICENSE_1_0.txt
// http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt
//
// File Version: 5.0.1 (2010/10/01)
#ifndef WM5LINEARSYSTEM_H
#define WM5LINEARSYSTEM_H
#include "Wm5MathematicsLIB.h"
#include "Wm5BandedMatrix.h"
#include "Wm5GMatrix.h"
namespace Wm5
{
template <typename Real>
class WM5_MATHEMATICS_ITEM LinearSystem
{
public:
// Construction and destruction.
LinearSystem ();
~LinearSystem ();
// 2x2 and 3x3 systems (avoids overhead of Gaussian elimination)
bool Solve2 (const Real A[2][2], const Real B[2], Real X[2]);
bool Solve3 (const Real A[3][3], const Real B[3], Real X[3]);
// Input:
// A[iSize][iSize], entries are A[row][col]
// Output:
// return value is TRUE if successful, FALSE if pivoting failed
// InvA[iSize][iSize], inverse matrix
bool Inverse (const GMatrix<Real>& A, GMatrix<Real>& invA);
// Input:
// A[iSize][iSize] coefficient matrix, entries are A[row][col]
// B[iSize] vector, entries are B[row]
// Output:
// return value is TRUE if successful, FALSE if pivoting failed
// X[iSize] is solution X to AX = B
bool Solve (const GMatrix<Real>& A, const Real* B, Real* X);
// Input:
// Matrix is tridiagonal.
// Lower diagonal A[iSize-1]
// Main diagonal B[iSize]
// Upper diagonal C[iSize-1]
// Right-hand side R[iSize]
// Output:
// return value is TRUE if successful, FALSE if pivoting failed
// U[iSize] is solution
bool SolveTri (int size, Real* A, Real* B, Real* C, Real* R, Real* U);
// Input:
// Matrix is tridiagonal.
// Lower diagonal is constant, A
// Main diagonal is constant, B
// Upper diagonal is constant, C
// Right-hand side Rr[iSize]
// Output:
// return value is TRUE if successful, FALSE if pivoting failed
// U[iSize] is solution
bool SolveConstTri (int size, Real A, Real B, Real C, Real* R,
Real* U);
// Solution using the conjugate gradient method.
// Input:
// A[iSize][iSize] symmetrix matrix, entries are A[row][col]
// B[iSize] vector, entries are B[row]
// Output:
// X[iSize] is the solution x to Ax = B
bool SolveSymmetricCG (const GMatrix<Real>& A, const Real* B, Real* X);
// Conjugate gradient method for sparse, symmetric matrices.
// Input:
// The nonzero entries of the symmetrix matrix A are stored in a map
// whose keys are pairs (i,j) and whose values are real numbers. The
// pair (i,j) is the location of the value in the array. Only one of
// (i,j) and (j,i) should be stored since A is symmetric. The code
// assumes this is how you set up A. The column vector B is stored as
// an array of contiguous values.
// Output:
// X[iSize] is the solution x to Ax = B
typedef std::map<std::pair<int,int>,Real> SparseMatrix;
bool SolveSymmetricCG (int size, const SparseMatrix& A, const Real* B,
Real* X);
// Solve banded matrix systems.
// Input:
// A, a banded matrix
// B[iSize] vector, entries are B[row]
// Output:
// return value is TRUE if successful, FALSE if pivoting failed
// X[iSize] is solution X to AX = B
bool SolveBanded (const BandedMatrix<Real>& A, const Real* B, Real* X);
// Invert a banded matrix.
// Input:
// A, a banded matrix
// Output:
// return value is TRUE if the inverse exists, FALSE otherwise
// InvA, the inverse of A
bool Invert (const BandedMatrix<Real>& A, GMatrix<Real>& invA);
// Tolerance for linear system solving.
Real ZeroTolerance; // default = Math<Real>::ZERO_TOLERANCE
private:
// Support for the conjugate gradient method for standard arrays.
Real Dot (int size, const Real* U, const Real* V);
void Multiply (const GMatrix<Real>& A, const Real* X, Real* Prod);
void UpdateX (int size, Real* X, Real alpha, const Real* P);
void UpdateR (int size, Real* R, Real alpha, const Real* W);
void UpdateP (int size, Real* P, Real beta, const Real* R);
// Support for the conjugate gradient method for sparse arrays.
void Multiply (int size, const SparseMatrix& A, const Real* X,
Real* Prod);
// Support for banded matrices.
bool ForwardEliminate (int reduceRow, BandedMatrix<Real>& A, Real* B);
bool ForwardEliminate (int reduceRow, BandedMatrix<Real>& A,
GMatrix<Real>& B);
void BackwardEliminate (int reduceRow, BandedMatrix<Real>& A,
GMatrix<Real>& B);
};
typedef LinearSystem<float> LinearSystemf;
typedef LinearSystem<double> LinearSystemd;
}
#endif
|