[815] | 1 | // |
---|
| 2 | // ******************************************************************** |
---|
| 3 | // * License and Disclaimer * |
---|
| 4 | // * * |
---|
| 5 | // * The Geant4 software is copyright of the Copyright Holders of * |
---|
| 6 | // * the Geant4 Collaboration. It is provided under the terms and * |
---|
| 7 | // * conditions of the Geant4 Software License, included in the file * |
---|
| 8 | // * LICENSE and available at http://cern.ch/geant4/license . These * |
---|
| 9 | // * include a list of copyright holders. * |
---|
| 10 | // * * |
---|
| 11 | // * Neither the authors of this software system, nor their employing * |
---|
| 12 | // * institutes,nor the agencies providing financial support for this * |
---|
| 13 | // * work make any representation or warranty, express or implied, * |
---|
| 14 | // * regarding this software system or assume any liability for its * |
---|
| 15 | // * use. Please see the license in the file LICENSE and URL above * |
---|
| 16 | // * for the full disclaimer and the limitation of liability. * |
---|
| 17 | // * * |
---|
| 18 | // * This code implementation is the result of the scientific and * |
---|
| 19 | // * technical work of the GEANT4 collaboration. * |
---|
| 20 | // * By using, copying, modifying or distributing the software (or * |
---|
| 21 | // * any work based on the software) you agree to acknowledge its * |
---|
| 22 | // * use in resulting scientific publications, and indicate your * |
---|
| 23 | // * acceptance of all terms of the Geant4 Software license. * |
---|
| 24 | // ******************************************************************** |
---|
| 25 | // |
---|
| 26 | // $Id: G4ErrorSymMatrix.icc,v 1.2 2007/06/01 12:43:28 gcosmo Exp $ |
---|
[1058] | 27 | // GEANT4 tag $Name: geant4-09-02-ref-02 $ |
---|
[815] | 28 | // |
---|
| 29 | // ------------------------------------------------------------ |
---|
| 30 | // GEANT 4 class inline implementation |
---|
| 31 | // ------------------------------------------------------------ |
---|
| 32 | |
---|
| 33 | |
---|
| 34 | inline G4ErrorSymMatrix::G4ErrorSymMatrix() |
---|
| 35 | : m(0), nrow(0), size(0) |
---|
| 36 | { |
---|
| 37 | } |
---|
| 38 | |
---|
| 39 | inline G4int G4ErrorSymMatrix::num_row() const |
---|
| 40 | { |
---|
| 41 | return nrow; |
---|
| 42 | } |
---|
| 43 | |
---|
| 44 | inline G4int G4ErrorSymMatrix::num_col() const |
---|
| 45 | { |
---|
| 46 | return nrow; |
---|
| 47 | } |
---|
| 48 | |
---|
| 49 | inline G4int G4ErrorSymMatrix::num_size() const |
---|
| 50 | { |
---|
| 51 | return size; |
---|
| 52 | } |
---|
| 53 | |
---|
| 54 | inline G4double & G4ErrorSymMatrix::fast(G4int row,G4int col) |
---|
| 55 | { |
---|
| 56 | return *(m.begin()+(row*(row-1))/2+(col-1)); |
---|
| 57 | } |
---|
| 58 | |
---|
| 59 | inline const G4double & G4ErrorSymMatrix::fast(G4int row,G4int col) const |
---|
| 60 | { |
---|
| 61 | return *(m.begin()+(row*(row-1))/2+(col-1)); |
---|
| 62 | } |
---|
| 63 | |
---|
| 64 | inline G4double & |
---|
| 65 | G4ErrorSymMatrix::operator()(G4int row, G4int col) |
---|
| 66 | { |
---|
| 67 | return (row>=col? fast(row,col) : fast(col,row)); |
---|
| 68 | } |
---|
| 69 | |
---|
| 70 | inline const G4double & |
---|
| 71 | G4ErrorSymMatrix::operator()(G4int row, G4int col) const |
---|
| 72 | { |
---|
| 73 | return (row>=col? fast(row,col) : fast(col,row)); |
---|
| 74 | } |
---|
| 75 | |
---|
| 76 | inline void G4ErrorSymMatrix::assign(const G4ErrorSymMatrix &m2) |
---|
| 77 | { |
---|
| 78 | (*this)=m2; |
---|
| 79 | } |
---|
| 80 | |
---|
| 81 | inline G4ErrorSymMatrix G4ErrorSymMatrix::T() const |
---|
| 82 | { |
---|
| 83 | return G4ErrorSymMatrix(*this); |
---|
| 84 | } |
---|
| 85 | |
---|
| 86 | inline G4ErrorSymMatrix::G4ErrorSymMatrix_row |
---|
| 87 | G4ErrorSymMatrix::operator[] (G4int r) |
---|
| 88 | { |
---|
| 89 | G4ErrorSymMatrix_row b(*this,r); |
---|
| 90 | return b; |
---|
| 91 | } |
---|
| 92 | |
---|
| 93 | inline G4ErrorSymMatrix::G4ErrorSymMatrix_row_const |
---|
| 94 | G4ErrorSymMatrix::operator[] (G4int r) const |
---|
| 95 | { |
---|
| 96 | const G4ErrorSymMatrix_row_const b(*this,r); |
---|
| 97 | return b; |
---|
| 98 | } |
---|
| 99 | |
---|
| 100 | inline G4double &G4ErrorSymMatrix::G4ErrorSymMatrix_row::operator[](G4int c) |
---|
| 101 | { |
---|
| 102 | if (_r >= c ) |
---|
| 103 | { |
---|
| 104 | return *(_a.m.begin() + (_r+1)*_r/2 + c); |
---|
| 105 | } |
---|
| 106 | else |
---|
| 107 | { |
---|
| 108 | return *(_a.m.begin() + (c+1)*c/2 + _r); |
---|
| 109 | } |
---|
| 110 | } |
---|
| 111 | |
---|
| 112 | inline const G4double & |
---|
| 113 | G4ErrorSymMatrix::G4ErrorSymMatrix_row_const::operator[](G4int c) const |
---|
| 114 | { |
---|
| 115 | if (_r >= c ) |
---|
| 116 | { |
---|
| 117 | return *(_a.m.begin() + (_r+1)*_r/2 + c); |
---|
| 118 | } |
---|
| 119 | else |
---|
| 120 | { |
---|
| 121 | return *(_a.m.begin() + (c+1)*c/2 + _r); |
---|
| 122 | } |
---|
| 123 | } |
---|
| 124 | |
---|
| 125 | inline G4ErrorSymMatrix:: |
---|
| 126 | G4ErrorSymMatrix_row::G4ErrorSymMatrix_row(G4ErrorSymMatrix &a, G4int r) |
---|
| 127 | : _a(a), _r(r) |
---|
| 128 | {} |
---|
| 129 | |
---|
| 130 | inline G4ErrorSymMatrix:: |
---|
| 131 | G4ErrorSymMatrix_row_const::G4ErrorSymMatrix_row_const |
---|
| 132 | (const G4ErrorSymMatrix&a,G4int r) |
---|
| 133 | : _a(a), _r(r) |
---|
| 134 | {} |
---|
| 135 | |
---|
| 136 | inline G4ErrorSymMatrix G4ErrorSymMatrix::inverse(G4int &ifail) const |
---|
| 137 | { |
---|
| 138 | G4ErrorSymMatrix mTmp(*this); |
---|
| 139 | mTmp.invert(ifail); |
---|
| 140 | return mTmp; |
---|
| 141 | } |
---|