Library of Assembled Shared Sources
matrix_solve.inl File Reference
#include "../num_common.h"
#include "matrix_solve.h"
Include dependency graph for matrix_solve.inl:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  lass
 Library for Assembled Shared Sources.
 
namespace  lass::num
 numeric types and traits.
 

Functions

template<typename T, typename RandomIterator1, typename RandomIterator2>
bool lass::num::impl::ludecomp (RandomIterator1 ioMatrix, RandomIterator2 oIndex, std::ptrdiff_t iSize, int &iD)
 Given a complex matrix iA, this routine replaces it by the LU decomposition of a rowwise permutation of itself.
 
template<typename T, typename RandomIterator1, typename RandomIterator2, typename RandomIterator3>
void lass::num::impl::lusolve (RandomIterator1 iMatrix, RandomIterator2 iIndex, RandomIterator3 ioColumn, std::ptrdiff_t iSize)
 Solves the set of linear eqautions A X = B.
 
template<typename T, typename RandomIterator1, typename RandomIterator2, typename RandomIterator3, typename RandomIterator4, typename RandomIterator5>
void lass::num::impl::lumprove (RandomIterator1 iMatrix, RandomIterator2 iMatrixLU, RandomIterator3 iIndex, RandomIterator4 iColumn, RandomIterator5 ioX, std::ptrdiff_t iSize)
 Improves a solution vector X of the linear set of equations A X = B.
 
template<typename T, typename RandomIterator1, typename RandomIterator2>
bool lass::num::impl::cramer2 (RandomIterator1 iMatrixRowMajor, RandomIterator2 ioColumnFirst, RandomIterator2 ioColumnLast)
 Solve A X = B for 2x2 matrices with Cramer's rule.
 
template<typename T, typename RandomIterator1, typename RandomIterator2>
bool lass::num::impl::cramer3 (RandomIterator1 iMatrixRowMajor, RandomIterator2 ioColumnFirst, RandomIterator2 ioColumnLast)
 Solve A X = B for 3x3 matrices with Cramer's rule.
 
template<typename T, typename RandomIterator1, typename RandomIterator2, typename RandomIterator3>
bool lass::num::impl::solveTridiagonal (RandomIterator1 iA, RandomIterator1 iB, RandomIterator1 iC, RandomIterator2 ioSolution, RandomIterator3 ioTemp, std::ptrdiff_t iSize)
 Solve system of linear equations with a tridiagonal matrix.
 

Detailed Description

Author
Bram de Greve (bram@.nosp@m.coca.nosp@m.mware.nosp@m..com)
Tom De Muer (tom@c.nosp@m.ocam.nosp@m.ware..nosp@m.com)

*** BEGIN LICENSE INFORMATION ***

The contents of this file are subject to the Common Public Attribution License Version 1.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://lass.sourceforge.net/cpal-license. The License is based on the Mozilla Public License Version 1.1 but Sections 14 and 15 have been added to cover use of software over a computer network and provide for limited attribution for the Original Developer. In addition, Exhibit A has been modified to be consistent with Exhibit B.

Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License.

The Original Code is LASS - Library of Assembled Shared Sources.

The Initial Developer of the Original Code is Bram de Greve and Tom De Muer. The Original Developer is the Initial Developer.

All portions of the code written by the Initial Developer are: Copyright (C) 2004-2023 the Initial Developer. All Rights Reserved.

Contributor(s):

Alternatively, the contents of this file may be used under the terms of the GNU General Public License Version 2 or later (the GPL), in which case the provisions of GPL are applicable instead of those above. If you wish to allow use of your version of this file only under the terms of the GPL and not to allow others to use your version of this file under the CPAL, indicate your decision by deleting the provisions above and replace them with the notice and other provisions required by the GPL License. If you do not delete the provisions above, a recipient may use your version of this file under either the CPAL or the GPL.

*** END LICENSE INFORMATION ***

Definition in file matrix_solve.inl.

Function Documentation

◆ ludecomp()

template<typename T, typename RandomIterator1, typename RandomIterator2>
bool lass::num::impl::ludecomp ( RandomIterator1 ioMatrix,
RandomIterator2 oIndex,
std::ptrdiff_t iSize,
int & iD )

Given a complex matrix iA, this routine replaces it by the LU decomposition of a rowwise permutation of itself.

Parameters
ioMatrix[in,out]
  • Random iterator to first element of of a square matrix in row major order.
  • ioMatrix is replaced by its LU decomposition.
  • [ioMatrix, ioMatrix + iSize * iSize) must be a valid range
oIndex[out]
  • records the row permutations effected by the partial pivoting.
  • [oIndex, oIndex + iSize) must be a valid range.
iSize[in]
  • size of matrix
oD[out]
  • indicates the number of row interchanges was even (+1) or odd (-1).
Returns
- true: LU decomposition completed
  • false: matrix ioMatrix is singular

This routine is used in combination with lusolve() to solve linear equations and lumprove() to improve the solution.

Method: Crout's algorithm with partial pivoting.

Definition at line 85 of file matrix_solve.inl.

References lass::num::conj(), and lass::num::norm().

◆ cramer2()

template<typename T, typename RandomIterator1, typename RandomIterator2>
bool lass::num::impl::cramer2 ( RandomIterator1 iMatrixRowMajor,
RandomIterator2 ioColumnFirst,
RandomIterator2 ioColumnLast )

Solve A X = B for 2x2 matrices with Cramer's rule.

Parameters
iMatrix[in]
  • Random iterator to first element of matrix A in row major order.
  • A must be of size 2x2.
  • [iMatrix, iMatrix + 4) must be a valid range
ioColumn[in,out]
  • Random iterator to first element of B as input
  • Random iterator to first element of X as output
  • [iColumn, iColumn + 2) must be a valid range

Definition at line 344 of file matrix_solve.inl.

References lass::num::inv().