Epetra_SerialSymDenseMatrix.cpp

Go to the documentation of this file.
00001 
00002 //@HEADER
00003 // ************************************************************************
00004 // 
00005 //               Epetra: Linear Algebra Services Package 
00006 //                 Copyright (2001) Sandia Corporation
00007 // 
00008 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00009 // license for use of this work by or on behalf of the U.S. Government.
00010 // 
00011 // This library is free software; you can redistribute it and/or modify
00012 // it under the terms of the GNU Lesser General Public License as
00013 // published by the Free Software Foundation; either version 2.1 of the
00014 // License, or (at your option) any later version.
00015 //  
00016 // This library is distributed in the hope that it will be useful, but
00017 // WITHOUT ANY WARRANTY; without even the implied warranty of
00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019 // Lesser General Public License for more details.
00020 //  
00021 // You should have received a copy of the GNU Lesser General Public
00022 // License along with this library; if not, write to the Free Software
00023 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00024 // USA
00025 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 
00026 // 
00027 // ************************************************************************
00028 //@HEADER
00029 
00030 #include "Epetra_SerialSymDenseMatrix.h"
00031 //=============================================================================
00032 Epetra_SerialSymDenseMatrix::Epetra_SerialSymDenseMatrix(void)
00033   : Epetra_SerialDenseMatrix(),
00034     Upper_(false),
00035     UPLO_('L')
00036 
00037 {
00038 }
00039 //=============================================================================
00040 Epetra_SerialSymDenseMatrix::Epetra_SerialSymDenseMatrix(Epetra_DataAccess CV, double *A, int LDA, int NumRowsCols)
00041   : Epetra_SerialDenseMatrix(CV, A, LDA, NumRowsCols, NumRowsCols),
00042     Upper_(false),
00043     UPLO_('L')
00044 
00045 {
00046 }
00047 //=============================================================================
00048 Epetra_SerialSymDenseMatrix::Epetra_SerialSymDenseMatrix(const Epetra_SerialSymDenseMatrix& Source)
00049   : Epetra_SerialDenseMatrix(Source),  
00050     Upper_(Source.Upper_),
00051     UPLO_(Source.UPLO_)
00052 {
00053 }
00054 //=============================================================================
00055 Epetra_SerialSymDenseMatrix::~Epetra_SerialSymDenseMatrix()
00056 {
00057 }
00058 //=============================================================================
00059 void Epetra_SerialSymDenseMatrix::CopyUPLOMat(bool Upper, double * A, int LDA, int NumRows) {
00060 
00061   int i, j;
00062   double * ptr1;
00063   double * ptr2;
00064 
00065   if (Upper) {
00066     for (j=1; j<NumRows; j++) {
00067       ptr1 = A + j;
00068       ptr2 = A + j*LDA;
00069       for (i=0; i<j; i++) {
00070   *ptr1 = *ptr2++;
00071   ptr1+=LDA;
00072       }
00073     }
00074   }
00075   else {
00076     for (i=1; i<NumRows; i++) {
00077       ptr1 = A + i;
00078       ptr2 = A + i*LDA;
00079       for (j=0; j<i; j++) {
00080   *ptr2++ = *ptr1;
00081   ptr1+=LDA;
00082       }
00083     }
00084   }
00085 }
00086 //=============================================================================
00087 double Epetra_SerialSymDenseMatrix::NormOne(void) const{
00088 
00089     return(Epetra_SerialSymDenseMatrix::NormInf());
00090 }
00091 //=============================================================================
00092 double Epetra_SerialSymDenseMatrix::NormInf(void) const {
00093 
00094   int i, j;
00095 
00096   double anorm = 0.0;
00097   double * ptr;
00098 
00099   if (!Upper()) {
00100     for (j=0; j<N_; j++) {
00101       double sum = 0.0;
00102       ptr = A_ + j + j*LDA_;
00103       for (i=j; i<N_; i++) sum += std::abs(*ptr++);
00104       ptr = A_ + j;
00105       for (i=0; i<j; i++) {
00106   sum += std::abs(*ptr);
00107   ptr += LDA_;
00108       }
00109       anorm = EPETRA_MAX(anorm, sum);
00110     }
00111   }
00112   else {
00113     for (j=0; j<N_; j++) {
00114       double sum = 0.0;
00115       ptr = A_ + j*LDA_;
00116       for (i=0; i<j; i++) sum += std::abs(*ptr++);
00117       ptr = A_ + j + j*LDA_;
00118       for (i=j; i<N_; i++) {
00119   sum += std::abs(*ptr);
00120   ptr += LDA_;
00121       }
00122       anorm = EPETRA_MAX(anorm, sum);
00123     }
00124   }
00125   UpdateFlops(N_*N_);
00126   return(anorm);
00127 }
00128 
00129 //=============================================================================
00130 int Epetra_SerialSymDenseMatrix::Scale(double ScalarA) {
00131 
00132   int i, j;
00133 
00134   double * ptr;
00135 
00136   if (!Upper()) {
00137     for (j=0; j<N_; j++) {
00138       ptr = A_ + j + j*LDA_;
00139       for (i=j; i<N_; i++) {*ptr = *ptr * ScalarA; ptr++;}
00140     }
00141   }
00142   else {
00143     for (j=0; j<N_; j++) {
00144       ptr = A_ + j*LDA_;
00145       for (i=0; i<j; i++) {*ptr = *ptr * ScalarA; ptr++;}
00146     }
00147   }
00148   UpdateFlops(N_*(N_+1)/2);
00149   return(0);
00150 }
00151 

Generated on Thu Sep 18 12:37:58 2008 for Epetra Package Browser (Single Doxygen Collection) by doxygen 1.3.9.1