#include <bgmatrix.h>
Inheritance diagram for matvec::BGMatrix:

Public Types | |
| typedef int | size_type |
| typedef BG | value_type |
| typedef BG | element_type |
| typedef BG * | pointer |
| typedef BG * | iterator |
| typedef BG & | reference |
| typedef const BG * | const_iterator |
| typedef const BG * | const_pointer |
| typedef const BG & | const_reference |
| typedef std::reverse_iterator< iterator > | reverse_iterator |
| typedef std::reverse_iterator< const_iterator > | const_reverse_iterator |
Public Methods | |
| BGMatrix (void) | |
| BGMatrix (const doubleMatrix &a) | |
| BGMatrix (const size_type m, const size_type n) | |
| BGMatrix (const size_type m, const size_type n, const BG **a) | |
| BGMatrix (const BGMatrix &a) | |
| BGMatrix (const Matrix< BG > &a) | |
| BGMatrix & | operator= (const Matrix< BG > &a) |
| BGMatrix & | operator= (const Matrix< bool > &a) |
| bool | psd (void) const |
| BGMatrix & | inv () |
| BGMatrix | ginv0 (void) const |
| BGMatrix | splines (const BGMatrix knots, const unsigned type=0) const |
| BGMatrix & | ginv1 (unsigned *irank=0) |
| BGMatrix | mat_log (double tol=0.0) const |
| BGMatrix | mat_exp (double tol=0.0) const |
| void | mat_exp_der (Vector< BGMatrix > &der, double tol=0.0) const |
| BGMatrix | covariance (const BGMatrix &B) const |
| Vector< BG > | variance (orientation orien=COLUMN) const |
| BGMatrix | lu_solve (const BGMatrix &rhs) |
| Vector< BG > | lu_solve (const Vector< BG > &rhs) |
| void | gs_solve (const BGMatrix &v, BGMatrix &solmat, const double relax=1.0, const double stopval=0.001, const int mxiter=1000) |
| void | gs_solve (const Vector< BG > &v, Vector< BG > &solvec, const double relax=1.0, const double stopval=0.001, const int mxiter=1000) |
| BG | cond (void) |
| BG | det (void) const |
| BG | norm (const int p) const |
| BG | norm (const std::string &s) const |
| BG | logdet (void) |
| BG | quadratic (const Vector< BG > &a, const Vector< BG > &b) const |
| BGMatrix & | sqrtm (void) |
| BGMatrix & | identity (const int m, const int n) |
| BGMatrix & | identity (const int m) |
| BGMatrix & | identity (void) |
| bool | symmetric (void) const |
| BG ** | begin (void) |
| const BG ** | begin (void) const |
| void | copy (const Matrix &a) |
| Matrix & | assign (const Matrix &a) |
| Matrix & | assign (const BG &x) |
| Matrix & | resize (const size_type n, const size_type m, const BG &val=BG()) |
| Matrix & | resize (const size_type n, const size_type m, const BG *a) |
| Matrix & | resize (const Matrix &a) |
| Matrix & | reserve (const size_type n, const size_type m) |
| Matrix | operator+ (const Matrix &a) const |
| Matrix | operator+ (const BG &x) const |
| Matrix & | operator+ (void) |
| Matrix | operator- (const Matrix &a) const |
| Matrix | operator- (const BG &x) const |
| Matrix | operator- (void) const |
| Matrix | operator * (const Matrix &a) const |
| Vector< BG > | operator * (const Vector< BG > &a) const |
| Matrix | operator * (const BG &x) const |
| Matrix | operator/ (const Matrix &a) const |
| Matrix | operator/ (const BG &x) const |
| Matrix & | operator+= (const Matrix &a) |
| Matrix & | operator+= (const BG &x) |
| Matrix & | operator-= (const Matrix &a) |
| Matrix & | operator-= (const BG &x) |
| Matrix & | operator *= (const Matrix &a) |
| Matrix & | operator *= (const BG &x) |
| Matrix & | operator/= (const Matrix &a) |
| Matrix & | operator/= (const BG &x) |
| BG * | operator[] (const size_type i) |
| const BG * | operator[] (const size_type i) const |
| BG & | operator() (const size_type i, const size_type j) |
| Matrix< bool > | operator! (void) const |
| Matrix< bool > | operator== (const Matrix &a) const |
| Matrix< bool > | operator== (const BG &x) const |
| Matrix< bool > | operator< (const Matrix &a) const |
| Matrix< bool > | operator< (const BG &x) const |
| Matrix< bool > | operator> (const Matrix &a) const |
| Matrix< bool > | operator> (const BG &x) const |
| Matrix< bool > | operator!= (const Matrix &a) const |
| Matrix< bool > | operator!= (const BG &x) const |
| Matrix< bool > | operator<= (const Matrix &a) const |
| Matrix< bool > | operator<= (const BG &x) const |
| Matrix< bool > | operator>= (const Matrix &a) const |
| Matrix< bool > | operator>= (const BG &x) const |
| bool | all (void) const |
| bool | any (void) const |
| bool | empty (void) const |
| bool | save (const std::string &fname, const int io_mode=std::ios::out) const |
| Matrix | apply (BG(*f)(BG)) const |
| Matrix | apply (BG(*f)(BG, BG), const Matrix &b) const |
| Matrix | apply (BG(*f)(BG, BG), const BG &b) const |
| Matrix | submat (const size_type idx1, const size_type idx2, const int len1=0, const int len2=0) const |
| Matrix | submat (const Matrix< bool > &a) const |
| Matrix | transpose (void) const |
| Matrix | kron (const Matrix &b) const |
| Matrix | reshape (const size_type m, const size_type n, orientation orient=COLUMN) const |
| Matrix | diag (void) const |
| Vector< BG > | diag (const size_type k) const |
| Vector< BG > | vec (orientation orient=COLUMN) const |
| Vector< BG > | sum (orientation orient=COLUMN) const |
| Vector< BG > | sumsq (orientation orient=COLUMN) const |
| Vector< BG > | max (orientation orient=COLUMN) const |
| Vector< BG > | min (orientation orient=COLUMN) const |
| virtual std::ostream & | print (std::ostream &os=std::cout) const |
| BG | trace (BG init=BG()) const |
| BG & | at (const size_type i, const size_type j) |
| Matrix & | sortby (orientation orient, const size_type k) |
| int | size (void) const |
| int | num_rows (void) const |
| int | num_cols (void) const |
| void | clear (void) |
| void | input (const std::string &fname, const size_type m, const size_type n) |
| void | initialize (const size_type m, const size_type n, const BG **a) |
Public Attributes | |
| BG ** | me |
| int | nrow |
| int | ncol |
Friends | |
| class | Model |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Definition at line 44 of file matrix.h. Referenced by BGMatrix(). |
|
|
|
|
|
Definition at line 36 of file bgmatrix.h.
00036 : Matrix<BG>() {}
|
|
|
Definition at line 34 of file bgmatrix.cpp. References matvec::Matrix< double >::num_cols(), matvec::Matrix< double >::num_rows(), and matvec::Matrix< BG >::resize().
00035 {
00036 resize(a.num_rows(),a.num_cols());
00037 for (int j,i=0; i<a.num_rows(); ++i) {
00038 for (j=0; j<a.num_cols(); ++j) {
00039 Matrix<BG>::me[i][j] = a[i][j];
00040 }
00041 }
00042 }
|
|
||||||||||||
|
Definition at line 38 of file bgmatrix.h. References matvec::Matrix< BG >::size_type.
00038 : Matrix<BG>(m,n){}
|
|
||||||||||||||||
|
Definition at line 39 of file bgmatrix.h. References matvec::Matrix< BG >::size_type.
00039 : Matrix<BG>(m,n,a){}
|
|
|
Definition at line 40 of file bgmatrix.h.
00040 : Matrix<BG>(a) { }
|
|
|
Definition at line 41 of file bgmatrix.h.
00041 : Matrix<BG>(a) { }
|
|
|
|
|
|
|
|
||||||||||||
|
|
|
||||||||||||
|
|
|
|
|
|
|
|
|
|
Definition at line 81 of file matrix.h.
00081 {copy(a); return *this;}
|
|
||||||||||||
|
|
|
|
Definition at line 76 of file matrix.h.
00076 { return (const T**)me; }
|
|
|
Definition at line 75 of file matrix.h. Referenced by det(), ginv1(), identity(), psd(), and sqrtm().
00075 { return me; }
|
|
|
|
|
|
|
|
|
Referenced by operator=(). |
|
|
Definition at line 314 of file bgmatrix.cpp. References matvec::Matrix< BG >::me, matvec::Matrix< BG >::ncol, matvec::Matrix< BG >::nrow, matvec::Matrix< BG >::num_cols(), and matvec::Matrix< BG >::num_rows().
00315 {
00316 int nrow = Matrix<BG>::nrow;
00317 int ncol = Matrix<BG>::ncol;
00318 BG** me = Matrix<BG>::me;
00319
00320 assert (nrow == B.num_rows() && ncol == B.num_cols());
00321 BGMatrix temp(ncol,ncol);
00322 int i,j,k;
00323 BG ss,sx,sy;
00324 for (i=0; i<ncol; ++i) {
00325 for (j=0; j<=i; ++j) {
00326 for (ss=0.0,sx=0.0,sy=0.0,k=0; k<nrow; ++k) {
00327 ss += me[k][i]*B[k][j];
00328 sx += me[k][i];
00329 sy += B[k][j];
00330 }
00331 temp[i][j] = temp[j][i] = (ss - sx*sy/ncol)/(ncol - 1);
00332 }
00333 }
00334 return temp;
00335 }
|
|
|
Definition at line 223 of file bgmatrix.cpp. References matvec::Vector< T >::begin(), matvec::Matrix< BG >::begin(), matvec::Session::epsilon, matvec::ludcmp(), matvec::Matrix< BG >::ncol, matvec::Matrix< BG >::nrow, and matvec::SESSION.
00224 {
00225 int nrow = Matrix<BG>::nrow;
00226 int ncol = Matrix<BG>::ncol;
00227
00228 BG detval = 0.0;
00229 if ( nrow != ncol ) throw exception("BGMatrix::det(): matrix must be square");
00230 int i,d;
00231 Vector<int> indx(nrow);
00232 BGMatrix temp(*this);
00233 ludcmp(temp.begin(),nrow,indx.begin(),d, SESSION.epsilon);
00234 detval = (BG)d;
00235 for (i=0; i<nrow; i++) detval *= temp[i][i];
00236 return detval;
00237 }
|
|
|
|
|
|
|
|
|
Definition at line 138 of file matrix.h.
|
|
|
|
|
|
Definition at line 91 of file bgmatrix.cpp. References matvec::Matrix< BG >::begin(), matvec::Session::epsilon, matvec::ginverse1(), matvec::Matrix< BG >::num_rows(), matvec::SESSION, and symmetric().
00092 { // it only works for symmetric-positive-semidefinite matrix
00093 // Matrix itself becomes its inverse;
00094 if (!this->symmetric()) {
00095 throw exception("BGMatrix::ginv1(): matrix must be symmetric");
00096 }
00097 BG lgdet;
00098 unsigned myrank = ginverse1(begin(),num_rows(),lgdet,1,SESSION.epsilon);
00099 if (irank) *irank = myrank;
00100 return *this;
00101 }
|
|
||||||||||||||||||||||||
|
Definition at line 205 of file bgmatrix.cpp. References gs_solve(), matvec::Vector< T >::resize(), and matvec::Vector< T >::size().
00207 {
00208 int n = rhs.size();
00209 BGMatrix bmat(n,1),solmat(n,1);
00210 if (sol.size() != n) {
00211 sol.resize(n);
00212 }
00213 int i;
00214 for (i=0; i<n; i++) {
00215 bmat[i][0] = rhs[i];
00216 solmat[i][0] = sol[i];
00217 }
00218 gs_solve(bmat,solmat,relax,stopval,mxiter);
00219 for (i=0; i<n; i++) sol[i] = solmat[i][0];
00220 }
|
|
||||||||||||||||||||||||
|
Definition at line 139 of file bgmatrix.cpp. References matvec::Matrix< BG >::diag(), matvec::Session::epsilon, matvec::BG::f, matvec::Matrix< BG >::me, matvec::Matrix< BG >::ncol, matvec::Matrix< BG >::nrow, matvec::Matrix< BG >::num_cols(), matvec::Matrix< BG >::num_rows(), matvec::Matrix< BG >::resize(), matvec::SESSION, and matvec::warning(). Referenced by gs_solve().
00141 {
00142 // relax relaxation coefficient, relax=1.2 seems good for some case
00143 // stopval the accuracy at which iteration stops.
00144 // mxiter maximum number of iterations allowed
00145
00146 int nrow = Matrix<BG>::nrow;
00147 int ncol = Matrix<BG>::ncol;
00148 BG** me = Matrix<BG>::me;
00149
00150 int m = rhs.num_rows();
00151 int n = rhs.num_cols();
00152 if (nrow != ncol) throw exception("BGMatrix::gs_solve(): matrix must be square ");
00153 if (ncol != m ) throw exception("BGMatrix::gs_solve(): matrix and rhs are not conformable");
00154 if (solmat.num_rows() != m || solmat.num_cols() != n) {
00155 solmat.resize(m,n);
00156 }
00157 int i,j,k;
00158 BG diag;
00159 int niter = 0;
00160 BG a,cmax;
00161 BG tol = SESSION.epsilon;
00162
00163 Vector<BG> oldsol(n);
00164 Vector<BG> newsol(n);
00165 Vector<BG> cval(n);
00166 Vector<BG> local(n);
00167 do { // now iteration begins
00168 cmax = 0.0;
00169 for (i=0; i<m; i++) {
00170 for (k=0; k<n; k++) {
00171 oldsol[k] = solmat[i][k];
00172 local[k] = 0.0;
00173 }
00174 for (j=0; j<m; j++) {
00175 a = me[i][j];
00176 if (j != i) for (k=0; k<n; k++) local[k] += a * solmat[j][k];
00177 }
00178 diag = me[i][i];
00179 if (diag > tol) {
00180 for (k=0; k<n; k++) {
00181 newsol[k] = (rhs[i][k] - local[k])/diag;
00182 cval[k] = (newsol[k] - oldsol[k])*relax;
00183 if (fabs(cval[k]) > cmax) cmax = fabs(cval[k]);
00184 newsol[k] = solmat[i][k] = oldsol[k] + cval[k];
00185 }
00186 }
00187 else if (diag > -tol) {
00188 throw exception("BGMatrix::gs_solve(): zero-diagonal found in Matrix::gs_solve()");
00189 }
00190 else {
00191 throw exception("BGMatrix::gs_solve(): matrix is not psd");
00192 }
00193 }
00194 niter += 1;
00195 if ( (niter % 10) ==0) {
00196 std::cout << " GS: # of iter = " << niter << ", max_change = "
00197 << cmax << std::endl;
00198 }
00199 } while (niter <= mxiter && cmax > stopval);
00200 if (cmax > stopval) {
00201 warning("BGMatrix::gs_solve(): not converge: %20.10f",cmax.f);
00202 }
00203 }
|
|
|
Definition at line 75 of file bgmatrix.h. References matvec::Matrix< BG >::num_cols(), and matvec::Matrix< BG >::num_rows(). Referenced by identity().
|
|
|
Definition at line 74 of file bgmatrix.h. References identity().
00074 {return identity(m,m);}
|
|
||||||||||||
|
Definition at line 345 of file bgmatrix.cpp. References matvec::Matrix< BG >::begin(), matvec::Matrix< BG >::me, and matvec::Matrix< BG >::resize().
|
|
||||||||||||||||
|
|
|
||||||||||||||||
|
|
|
|
Definition at line 60 of file bgmatrix.cpp. References matvec::Vector< T >::assign(), matvec::Vector< T >::begin(), matvec::Session::epsilon, matvec::lubksb(), matvec::ludcmp(), matvec::Matrix< BG >::me, matvec::Matrix< BG >::ncol, matvec::Matrix< BG >::nrow, matvec::Matrix< T >::reserve(), matvec::Vector< T >::reserve(), and matvec::SESSION.
00061 {
00062 //////////////////////////////////////////////////////////
00063 // A itself turns into its inverse
00064 // returns non_singular indicator
00065 // REQUIREMENTS: A must be nonsingular
00066 /////////////////////////////////////////////////////////
00067 int nrow = Matrix<BG>::nrow;
00068 int ncol = Matrix<BG>::ncol;
00069 BG** me = Matrix<BG>::me;
00070
00071 int i,j,d;
00072 if ( nrow != ncol ) throw exception("BGMatrix::inv(): matrix must be square");
00073 Vector<int> indx; indx.reserve(nrow);
00074 Vector<BG> tempcol; tempcol.reserve(nrow);
00075 Matrix<BG> temp; temp.reserve(nrow,nrow);
00076
00077 ludcmp(me,nrow,indx.begin(),d, SESSION.epsilon);
00078 for (j=0; j<nrow; j++) {
00079 tempcol.assign(0.0);
00080 tempcol[j] = 1.0;
00081 lubksb(me,nrow,indx.begin(),tempcol.begin());
00082 for (i=0; i<nrow;i++) temp[i][j] = tempcol[i];
00083 }
00084 //for (i=0;i<nrow; i++) memcpy(me[i],temp[i],sizeof(BG)*nrow);
00085 for (j=0; j<nrow; j++) {
00086 for (i=0; i<nrow;i++) me[i][j] = temp[i][j];
00087 }
00088 return *this;
00089 }
|
|
|
|
|
|
Definition at line 253 of file bgmatrix.cpp. References matvec::Matrix< T >::begin(), matvec::Session::epsilon, matvec::ginverse1(), matvec::Matrix< BG >::me, matvec::Matrix< BG >::ncol, matvec::Matrix< BG >::nrow, matvec::SESSION, and symmetric().
00254 {
00255 int nrow = Matrix<BG>::nrow;
00256 int ncol = Matrix<BG>::ncol;
00257 BG** me = Matrix<BG>::me;
00258
00259 BG retval = 0.0;
00260 if (!this->symmetric()) throw exception("BGMatrix::logdet(): matrix must be symmetric");
00261 Matrix<BG> temp(*this);
00262
00263 ginverse1(temp.begin(),nrow,retval,3,SESSION.epsilon);
00264 return retval;
00265 }
|
|
|
Definition at line 129 of file bgmatrix.cpp. References lu_solve(), matvec::Vector< T >::size(), and matvec::Matrix< BG >::vec().
|
|
|
Definition at line 104 of file bgmatrix.cpp. References matvec::Vector< T >::begin(), matvec::Session::epsilon, matvec::lubksb(), matvec::ludcmp(), matvec::Matrix< BG >::me, matvec::Matrix< BG >::ncol, matvec::Matrix< BG >::nrow, matvec::Matrix< BG >::num_cols(), matvec::Matrix< BG >::num_rows(), matvec::Vector< T >::reserve(), matvec::SESSION, and matvec::warning(). Referenced by lu_solve().
00105 {
00106 int nrow = Matrix<BG>::nrow;
00107 int ncol = Matrix<BG>::ncol;
00108 BG** me = Matrix<BG>::me;
00109
00110 if (nrow != ncol) throw exception("BGMatrix::lu_solve(): matrix is not square ");
00111 int m = rhs.num_rows();
00112 int n = rhs.num_cols();
00113
00114 if (ncol != m ) throw exception("BGMatrix::lu_solve(): bad arg");
00115 BGMatrix solmat(m,n);
00116 int i,j,d;
00117 Vector<BG> solvec; solvec.reserve(m);
00118 Vector<int> indx; indx.reserve(m);
00119 ludcmp(me,nrow,indx.begin(),d,SESSION.epsilon);
00120 warning("A.solve(b), A destroyed");
00121 for (j=0; j<n; j++) {
00122 for (i=0; i<m; i++) solvec[i] = rhs[i][j];
00123 lubksb(me,m,indx.begin(),solvec.begin());
00124 for (i=0; i<m; i++) solmat[i][j] = solvec[i];
00125 }
00126 return solmat;
00127 }
|
|
|
|
|
||||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
Definition at line 240 of file bgmatrix.cpp. References matvec::Matrix< BG >::diag(), matvec::sqrt(), matvec::Matrix< BG >::sum(), and matvec::Matrix< BG >::transpose().
|
|
|
|
|
|
Definition at line 163 of file matrix.h. Referenced by covariance(), gs_solve(), identity(), and lu_solve().
00163 { return ncol; }
|
|
|
Definition at line 162 of file matrix.h. Referenced by covariance(), ginv1(), gs_solve(), identity(), lu_solve(), and sqrtm().
00162 { return nrow; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||||||||||||
|
|
|
|
Definition at line 117 of file matrix.h.
00117 { return *this; } //unary plus
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Definition at line 44 of file bgmatrix.cpp. References matvec::Matrix< T >::num_cols(), matvec::Matrix< T >::num_rows(), and matvec::Matrix< BG >::resize().
00045 {
00046 resize(a.num_rows(),a.num_cols());
00047 for (int j,i=0; i<a.num_rows(); ++i) for (j=0; j<a.num_cols(); ++j) Matrix<BG>::me[i][j] = (BG)a[i][j];
00048 return *this;
00049 }
|
|
|
Definition at line 43 of file bgmatrix.h. References matvec::Matrix< BG >::copy().
00043 { copy(a); return *this; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Definition at line 114 of file matrix.h.
00114 { return me[i]; }
|
|
|
Definition at line 113 of file matrix.h.
00113 { return me[i]; }
|
|
|
|
|
|
Definition at line 52 of file bgmatrix.cpp. References matvec::Matrix< BG >::begin(), matvec::Session::epsilon, matvec::Matrix< BG >::ncol, matvec::Matrix< BG >::nrow, matvec::psdefinite(), matvec::SESSION, and symmetric().
|
|
||||||||||||
|
Definition at line 267 of file bgmatrix.cpp. References matvec::Matrix< BG >::me, matvec::Matrix< BG >::ncol, matvec::Matrix< BG >::nrow, and matvec::Vector< T >::size().
00268 {
00269 int nrow = Matrix<BG>::nrow;
00270 int ncol = Matrix<BG>::ncol;
00271 BG** me = Matrix<BG>::me;
00272 int m = x.size();
00273 int n = y.size();
00274
00275 BG s = 0.0;
00276 if (m != nrow || n != ncol) throw exception("BGMatrix::quadratic(): size not conformable");
00277 for (int j,i=0;i<m; i++) for (j=0; j<n; j++) s += x[i]*me[i][j]*y[j];
00278 return s;
00279 }
|
|
||||||||||||
|
|
|
||||||||||||||||
|
|
|
|
Definition at line 86 of file matrix.h.
00086 {resize(a.ne); return *this;}
|
|
||||||||||||||||
|
|
|
||||||||||||||||
|
Referenced by BGMatrix(), gs_solve(), identity(), and operator=(). |
|
||||||||||||
|
|
|
|
Definition at line 161 of file matrix.h.
|
|
||||||||||||
|
|
|
||||||||||||
|
|
|
|
Definition at line 337 of file bgmatrix.cpp. References matvec::Matrix< BG >::begin(), matvec::Session::epsilon, matvec::ginverse1(), matvec::Matrix< BG >::num_rows(), matvec::SESSION, and symmetric().
|
|
|
|
|
||||||||||||||||||||
|
|
|
|
Referenced by norm(). |
|
|
|
|
|
Reimplemented from matvec::Matrix< BG >. Definition at line 78 of file bgmatrix.h. References matvec::Session::epsilon, matvec::Matrix< BG >::me, matvec::Matrix< BG >::nrow, and matvec::SESSION. Referenced by ginv1(), logdet(), psd(), and sqrtm().
|
|
|
|
|
|
Referenced by norm(). |
|
|
Definition at line 280 of file bgmatrix.cpp. References matvec::Matrix< BG >::COLUMN, matvec::Matrix< BG >::me, matvec::Matrix< BG >::ncol, matvec::Matrix< BG >::nrow, matvec::Vector< T >::resize(), matvec::Matrix< BG >::ROW, and matvec::warning().
00281 {
00282 int nrow = Matrix<BG>::nrow;
00283 int ncol = Matrix<BG>::ncol;
00284 BG** me = Matrix<BG>::me;
00285 int i,j;
00286 BG ss,s;
00287 Vector<BG> temp;
00288 if (orien == COLUMN) {
00289 assert(nrow > 1);
00290 temp.resize(ncol);
00291 for (j=0; j<ncol; j++) {
00292 for (ss=0.0,s=0.0,i=0; i<ncol; ++i) {
00293 ss += me[i][j]*me[i][j];
00294 s += me[i][j];
00295 }
00296 temp[j] = (ss-s*s/nrow)/(nrow - 1);
00297 }
00298 } else if (orien == ROW) {
00299 assert(ncol > 1);
00300 temp.resize(nrow);
00301 for (i=0; i<nrow; i++) {
00302 for (ss=0.0,s=0.0,j=0; j<ncol; ++j) {
00303 ss += me[i][j]*me[i][j];
00304 s += me[i][j];
00305 }
00306 temp[i] = (ss-s*s/ncol)/(ncol - 1);
00307 }
00308 } else {
00309 warning("unknown orientation");
00310 }
00311 return temp;
00312 }
|
|
|
Referenced by lu_solve(). |
|
|
Definition at line 34 of file bgmatrix.h. |
|
|
Definition at line 170 of file matrix.h. Referenced by covariance(), gs_solve(), identity(), inv(), logdet(), lu_solve(), quadratic(), symmetric(), and variance(). |
|
|
Definition at line 171 of file matrix.h. Referenced by covariance(), det(), gs_solve(), inv(), logdet(), lu_solve(), psd(), quadratic(), and variance(). |
|
|
Definition at line 171 of file matrix.h. Referenced by covariance(), det(), gs_solve(), inv(), logdet(), lu_solve(), psd(), quadratic(), symmetric(), and variance(). |
1.2.16