MatrixUtil.cpp

Go to the documentation of this file.
00001 /* ****************************************************************** **
00002 **    OpenSees - Open System for Earthquake Engineering Simulation    **
00003 **          Pacific Earthquake Engineering Research Center            **
00004 **                                                                    **
00005 **                                                                    **
00006 ** (C) Copyright 1999, The Regents of the University of California    **
00007 ** All Rights Reserved.                                               **
00008 **                                                                    **
00009 ** Commercial use of this program without express permission of the   **
00010 ** University of California, Berkeley, is strictly prohibited.  See   **
00011 ** file 'COPYRIGHT'  in main directory for information on usage and   **
00012 ** redistribution,  and for a DISCLAIMER OF ALL WARRANTIES.           **
00013 **                                                                    **
00014 ** Developed by:                                                      **
00015 **   Frank McKenna (fmckenna@ce.berkeley.edu)                         **
00016 **   Gregory L. Fenves (fenves@ce.berkeley.edu)                       **
00017 **   Filip C. Filippou (filippou@ce.berkeley.edu)                     **
00018 **                                                                    **
00019 ** ****************************************************************** */
00020                                                                         
00021 // $Revision: 1.5 $
00022 // $Date: 2003/04/04 16:55:03 $
00023 // $Source: /usr/local/cvs/OpenSees/SRC/element/nonlinearBeamColumn/matrixutil/MatrixUtil.cpp,v $
00024  
00025 #include <math.h>
00026                                                                         
00027 #include <stdlib.h>
00028 #include <Vector.h>
00029 #include <MatrixUtil.h>
00030 
00031 
00032 double invert2by2Matrix(const Matrix &a, Matrix &b)
00033 {
00034   return a.Invert(b);
00035 
00036   /*
00037     double det = a(0,0)*a(1,1)-a(0,1)*a(1,0);
00038     
00039     if (det != 0.0) {
00040     b(0,0) =  a(1,1)/det;
00041     b(1,1) =  a(0,0)/det;
00042     b(1,0) = -a(0,1)/det;
00043     b(0,1) = -a(1,0)/det;
00044     }
00045     return det;
00046   */
00047 }
00048 
00049 
00050 
00051 double invert3by3Matrix(const Matrix &a, Matrix &b)
00052 {
00053   return a.Invert(b);
00054 
00055     /*
00056    double a00, a01, a02, a11, a12, a22;
00057    double a01a01, a02a02, a12a12, a00a11, a01a02;
00058    double det;
00059                
00060    a00 = a(0,0);
00061    a01 = a(0,1);
00062    a02 = a(0,2);
00063    a11 = a(1,1);
00064    a12 = a(1,2);
00065    a22 = a(2,2);
00066    a01a01 = a01 * a01;
00067    a02a02 = a02 * a02;
00068    a12a12 = a12 * a12;
00069    a00a11 = a00 * a11;
00070    a01a02 = a01 * a02;
00071  
00072    det =  a00a11*a22 + 2 * a01a02*a12 - (a00*a12a12 + a01a01*a22 + a02a02*a11);
00073 
00074    if (det != 0) {
00075       b(0,0) = (a11*a22 - a12a12 )/det;
00076       b(0,1) = (a02*a12 - a01*a22)/det;    
00077       b(0,2) = (a01*a12 - a02*a11)/det;
00078       b(1,0) = b(0,1);
00079       b(1,1) = (a00*a22 - a02a02 )/det;
00080       b(1,2) = (a01a02  - a00*a12)/det;
00081       b(2,0) = b(0,2);
00082       b(2,1) = b(1,2);
00083       b(2,2) = (a00a11  - a01a01 )/det;
00084    }
00085    return det;
00086     */
00087 }
00088       
00089 
00090   
00091       
00092 void invertMatrix(int n, const Matrix &a, Matrix &b)
00093 {
00094   a.Invert(b);
00095 }
00096 
00097 
00098 
00099 void getCBDIinfluenceMatrix(int nIntegrPts, const Matrix &xi_pt, double L, Matrix &ls)
00100 {
00101    // setup Vandermode and CBDI influence matrices
00102    int i, j, i0, j0;
00103    double xi;
00104    Matrix G(nIntegrPts, nIntegrPts); 
00105    Matrix Ginv(nIntegrPts, nIntegrPts);
00106    Matrix l(nIntegrPts, nIntegrPts);
00107    Matrix I(nIntegrPts,nIntegrPts);      // an identity matrix for matrix inverse
00108 
00109    for (i = 1; i <= nIntegrPts; i++)
00110       for (j = 1; j <= nIntegrPts; j++)
00111       {
00112          i0 = i - 1;
00113          j0 = j - 1;
00114          xi = xi_pt(i0,0);
00115          G(i0,j0) =  pow(xi,j-1);
00116          l(i0,j0) = (pow(xi,j+1)-xi)/(j*(j+1));
00117       }
00118    
00119    I.Zero();
00120    for (i=0; i<nIntegrPts; i++)
00121      I(i,i) = 1.0;
00122 
00123    //invertMatrix(nIntegrPts, G, Ginv);
00124    if (G.Solve(I,Ginv) < 0)
00125      opserr << "LargeDispBeamCol3d::getCBDIinfluenceMatrix() - could not invert G\n";
00126       
00127    // ls = l * Ginv * (L*L);
00128    ls.addMatrixProduct(0.0, l, Ginv, L*L);
00129 }
00130 
00131 void getCBDIinfluenceMatrix(int nIntegrPts, double *pts, double L, Matrix &ls)
00132 {
00133    // setup Vandermode and CBDI influence matrices
00134    int i, j, i0, j0;
00135    double xi;
00136    Matrix G(nIntegrPts, nIntegrPts); 
00137    Matrix Ginv(nIntegrPts, nIntegrPts);
00138    Matrix l(nIntegrPts, nIntegrPts);
00139    Matrix I(nIntegrPts,nIntegrPts);      // an identity matrix for matrix inverse
00140 
00141    for (i = 1; i <= nIntegrPts; i++)
00142       for (j = 1; j <= nIntegrPts; j++)
00143       {
00144          i0 = i - 1;
00145          j0 = j - 1;
00146          xi = pts[i0];
00147          G(i0,j0) =  pow(xi,j-1);
00148          l(i0,j0) = (pow(xi,j+1)-xi)/(j*(j+1));
00149       }
00150    
00151    I.Zero();
00152    for (i=0; i<nIntegrPts; i++)
00153      I(i,i) = 1.0;
00154 
00155    //invertMatrix(nIntegrPts, G, Ginv);
00156    if (G.Solve(I,Ginv) < 0)
00157      opserr << "LargeDispBeamCol3d::getCBDIinfluenceMatrix() - could not invert G\n";
00158       
00159    // ls = l * Ginv * (L*L);
00160    ls.addMatrixProduct(0.0, l, Ginv, L*L);
00161 }
00162 
00163 
00164 
00165 
00166 

Generated on Mon Oct 23 15:05:09 2006 for OpenSees by doxygen 1.5.0