Changeset 926 in Sophya for trunk/SophyaLib/TArray/sopemtx.h


Ignore:
Timestamp:
Apr 13, 2000, 8:39:39 PM (25 years ago)
Author:
ansari
Message:

documentation cmv 13/4/00

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaLib/TArray/sopemtx.h

    r850 r926  
    77#include "tvector.h"
    88
     9// doivent imperativement reste avant le namespace SOPHYA !
     10/*!
     11  \class SOPHYA::SimpleMatrixOperation
     12  \ingroup TArray
     13  Class for simple operation on TMatrix
     14  \sa TMatrix TArray
     15  */
     16/*!
     17  \class SOPHYA::LinFitter
     18  \ingroup TArray
     19  Class for linear fitting
     20  \sa TMatrix TArray
     21  */
     22
    923namespace SOPHYA {
    1024
    11 
    12 
    1325////////////////////////////////////////////////////////////////
     26//! Class for simple operation on TMatrix
    1427template <class T>
    1528class SimpleMatrixOperation {
    1629public:
    17   // Pivot de Gauss : diagonalise la matrice A, en effectuant les memes
    18   // operations sur la matrice B
    1930  static TMatrix<T> Inverse(TMatrix<T> const & A);
    2031  static T GausPiv(TMatrix<T>& A, TMatrix<T>& B);
    2132};
    2233
     34////////////////////////////////////////////////////////////////
    2335// Resolution du systeme A*C = B
     36//! Solve A*C = B for C in place and return determinant
     37/*! \ingroup TArray \fn LinSolveInPlace */
     38inline r_4 LinSolveInPlace(TMatrix<r_4>& a, TVector<r_4>& b)
     39{
     40if(a.NCols() != b.NRows() || a.NCols() != a.NRows())
     41  throw(SzMismatchError("LinSolveInPlace(TMatrix<r_4>,TVector<r_4>) size mismatch"));
     42return SimpleMatrixOperation<r_4>::GausPiv(a,b);
     43}
     44
     45//! Solve A*X = B in place and return determinant
     46/*! \ingroup TArray \fn LinSolveInPlace */
    2447inline r_8 LinSolveInPlace(TMatrix<r_8>& a, TVector<r_8>& b)
    2548{
     
    2952}
    3053
    31 // Resolution du systeme A*C = B, avec C retourne dans B
    32 inline r_8 LinSolve(const TMatrix<r_8>& a, const TVector<r_8>& b, TVector<r_8>& c)
    33 {
     54//! Solve A*X = B in place and return determinant
     55/*! \ingroup TArray \fn LinSolveInPlace */
     56inline complex<r_4> LinSolveInPlace(TMatrix< complex<r_4> >& a, TVector< complex<r_4> >& b)
     57{
    3458if(a.NCols() != b.NRows() || a.NCols() != a.NRows())
    35   throw(SzMismatchError("LinSolve(TMatrix<r_8>,TVector<r_8>) size mismatch"));
    36 c = b;
    37 TMatrix<r_8> a1(a);
    38 return SimpleMatrixOperation<r_8>::GausPiv(a1,c);
     59  throw(SzMismatchError("LinSolveInPlace(TMatrix< complex<r_4> >,TVector< complex<r_4> >) size mismatch"));
     60return SimpleMatrixOperation< complex<r_4> >::GausPiv(a,b);
    3961}
    4062
    41 inline r_4 LinSolve(const TMatrix<r_4>& a, const TVector<r_4>& b, TVector<r_4>& c)
    42 {
     63//! Solve A*X = B in place and return determinant
     64/*! \ingroup TArray \fn LinSolveInPlace */
     65inline complex<r_8> LinSolveInPlace(TMatrix< complex<r_8> >& a, TVector< complex<r_8> >& b)
     66{
    4367if(a.NCols() != b.NRows() || a.NCols() != a.NRows())
    44   throw(SzMismatchError("LinSolve(TMatrix<r_4>,TVector<r_4>) size mismatch"));
    45 c = b;
    46 TMatrix<r_4> a1(a);
    47 return SimpleMatrixOperation<r_4>::GausPiv(a1,c);
     68  throw(SzMismatchError("LinSolveInPlace(TMatrix< complex<r_8> >,TVector< complex<r_8> >) size mismatch"));
     69return SimpleMatrixOperation< complex<r_8> >::GausPiv(a,b);
    4870}
    4971
    50 // Inverse d'une matrice
    51 inline TMatrix<r_8> Inverse(TMatrix<r_8> const & A)
    52 {
    53   return SimpleMatrixOperation<r_8>::Inverse(A);
     72////////////////////////////////////////////////////////////////
     73// Resolution du systeme A*C = B, avec C retourne dans B
     74//! Solve A*C = B and return C and determinant
     75/*! \ingroup TArray \fn LinSolve */
     76inline r_4 LinSolve(const TMatrix<r_4>& a, const TVector<r_4>& b, TVector<r_4>& c) {
     77  if(a.NCols()!=b.NRows() || a.NCols()!=a.NRows())
     78    throw(SzMismatchError("LinSolve(TMatrix<r_4>,TVector<r_4>) size mismatch"));
     79    c = b; TMatrix<r_4> a1(a);
     80  return SimpleMatrixOperation<r_4>::GausPiv(a1,c);
    5481}
    5582
    56 inline TMatrix<r_4> Inverse(TMatrix<r_4> const & A)
    57 {
    58   return SimpleMatrixOperation<r_4>::Inverse(A);
     83//! Solve A*C = B and return C and determinant
     84/*! \ingroup TArray \fn LinSolve */
     85inline r_8 LinSolve(const TMatrix<r_8>& a, const TVector<r_8>& b, TVector<r_8>& c) {
     86  if(a.NCols()!=b.NRows() || a.NCols()!=a.NRows())
     87    throw(SzMismatchError("LinSolve(TMatrix<r_8>,TVector<r_8>) size mismatch"));
     88    c = b; TMatrix<r_8> a1(a);
     89  return SimpleMatrixOperation<r_8>::GausPiv(a1,c);
    5990}
    6091
     92//! Solve A*C = B and return C and determinant
     93/*! \ingroup TArray \fn LinSolve */
     94inline complex<r_4> LinSolve(const TMatrix< complex<r_4> >& a, const TVector< complex<r_4> >& b, TVector< complex<r_4> >& c) {
     95  if(a.NCols()!=b.NRows() || a.NCols()!=a.NRows())
     96    throw(SzMismatchError("LinSolve(TMatrix< complex<r_4> >,TVector< complex<r_4> >) size mismatch"));
     97    c = b; TMatrix< complex<r_4> > a1(a);
     98  return SimpleMatrixOperation< complex<r_4> >::GausPiv(a1,c);
     99}
     100
     101//! Solve A*C = B and return C and determinant
     102/*! \ingroup TArray \fn LinSolve */
     103inline complex<r_8> LinSolve(const TMatrix< complex<r_8> >& a, const TVector< complex<r_8> >& b, TVector< complex<r_8> >& c) {
     104  if(a.NCols()!=b.NRows() || a.NCols()!=a.NRows())
     105    throw(SzMismatchError("LinSolve(TMatrix< complex<r_8> >,TVector< complex<r_8> >) size mismatch"));
     106    c = b; TMatrix< complex<r_8> > a1(a);
     107  return SimpleMatrixOperation< complex<r_8> >::GausPiv(a1,c);
     108}
     109
     110////////////////////////////////////////////////////////////////
     111// Inverse d'une matrice
     112//! To inverse a TMatrix
     113/*! \ingroup TArray \fn Inverse */
     114inline TMatrix<r_4> Inverse(TMatrix<r_4> const & A)
     115  {return SimpleMatrixOperation<r_4>::Inverse(A);}
     116//! To inverse a TMatrix
     117/*! \ingroup TArray \fn Inverse */
     118inline TMatrix<r_8> Inverse(TMatrix<r_8> const & A)
     119  {return SimpleMatrixOperation<r_8>::Inverse(A);}
     120//! To inverse a TMatrix
     121/*! \ingroup TArray \fn Inverse */
     122inline TMatrix< complex<r_4> > Inverse(TMatrix< complex<r_4> > const & A)
     123  {return SimpleMatrixOperation< complex<r_4> >::Inverse(A);}
     124//! To inverse a TMatrix
     125/*! \ingroup TArray \fn Inverse */
     126inline TMatrix< complex<r_8> > Inverse(TMatrix< complex<r_8> > const & A)
     127  {return SimpleMatrixOperation< complex<r_8> >::Inverse(A);}
    61128
    62129//--------------------------------------
     
    64131//--------------------------------------
    65132
     133//!  Class for linear fitting
    66134class LinFitter {
    67135public :
Note: See TracChangeset for help on using the changeset viewer.