Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

bg.h

Go to the documentation of this file.
00001 //****************************************************
00002 //****************************************************
00003 //  April, 1993, University of Illinois
00004 // Copyright (C) 1993, 1994 Tianlin Wang
00005 /* Copyright (C) 1994-2003 Matvec Development Team. 
00006 
00007   This program is free software; you can redistribute it and/or
00008   modify it under the terms of the GNU Library General Public
00009   License as published by the Free Software Foundation; either
00010   version 2 of the License, or (at your option) any later version.
00011   
00012   This program is distributed in the hope that it will be useful,
00013   but WITHOUT ANY WARRANTY; without even the implied warranty of
00014   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015   Library General Public License for more details.
00016     
00017   You should have received a copy of the GNU Library General Public
00018   License along with this library; if not, write to the Free
00019   Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
00020   MA 02111-1307, USA 
00021 */
00022 
00023 #include "doublematrix.h"
00024 #include <cmath>
00025 #include <iostream>
00026 #ifndef BG_H
00027 #define BG_H
00028 
00029 namespace matvec {
00030 
00031 
00032   class BG{
00033   public:
00034     static unsigned       dimen;
00035     static doubleMatrix   x;
00036     double                f;
00037     doubleMatrix          d;
00038     doubleMatrix          D;
00039 
00040     BG();
00041     BG(unsigned x_i, double b);
00042     BG(double a);
00043     BG(const BG &a);
00044     
00045     static void set_dimen(unsigned i){
00046       dimen = i;
00047       x.resize(dimen,1,0.0);
00048     }
00049     BG& initialize(unsigned i, double b);
00050 
00051     friend BG operator+(const BG &a, const BG &b);
00052     friend BG operator-(const BG &a, const BG &b);
00053     friend BG operator*(const BG &a, const BG &b);
00054     friend BG operator/(const BG &a, const BG &b); 
00055     friend BG operator-(const BG &a); 
00056     friend BG operator/(double a, const BG &b);
00057     friend BG operator+(double a, const BG &b);
00058     friend BG operator-(double a, const BG &b);
00059     friend BG operator*(double a, const BG &b);
00060 
00061     friend BG   operator+ (const BG &a, double b);
00062     friend BG   operator- (const BG &a, double b);
00063     friend BG   operator* (const BG &a, double b);
00064     friend BG   operator/ (const BG &a, double b);
00065     
00066     friend bool operator<=(const BG &a, double b){return a.f<=b;};
00067     friend bool operator< (const BG &a, double b){return a.f< b;};
00068     friend bool operator>=(const BG &a, double b){return a.f>=b;};
00069     friend bool operator> (const BG &a, double b){return a.f> b;};
00070     friend bool operator==(const BG &a, double b){return a.f==b;};
00071     friend bool operator!=(const BG &a, double b){return a.f!=b;};
00072                                    
00073     friend bool operator<=(const BG &a, const BG &b){return a.f<=b.f;};
00074     friend bool operator< (const BG &a, const BG &b){return a.f< b.f;};
00075     friend bool operator>=(const BG &a, const BG &b){return a.f>=b.f;};
00076     friend bool operator> (const BG &a, const BG &b){return a.f> b.f;};
00077     friend bool operator==(const BG &a, const BG &b){return a.f==b.f;};
00078     friend bool operator!=(const BG &a, const BG &b){return a.f!=b.f;};
00079 
00080     friend bool operator<=(double b, const BG &a){return b<=a.f;};
00081     friend bool operator< (double b, const BG &a){return b< a.f;};
00082     friend bool operator>=(double b, const BG &a){return b>=a.f;};
00083     friend bool operator> (double b, const BG &a){return b> a.f;};
00084     friend bool operator==(double b, const BG &a){return b==a.f;};
00085     friend bool operator!=(double b, const BG &a){return b!=a.f;};
00086 
00087 
00088     friend BG& operator+=(BG &a, const BG &b);
00089     friend BG& operator-=(BG &a, const BG &b);
00090     friend BG& operator*=(BG &a, const BG &b);
00091     friend BG& operator/=(BG &a, const BG &b);
00092     friend BG& operator+=(BG &a, double b);
00093     friend BG& operator-=(BG &a, double b);
00094     friend BG& operator*=(BG &a, double b);
00095     friend BG& operator/=(BG &a, double b);
00096     
00097 
00098     BG& operator=(double b);
00099     //BG& operator=(BG& a);
00100     //BG& operator=(BG a);
00101 
00102     friend BG sqrt(const BG &a);
00103     friend BG log (const BG &a);
00104     friend BG exp (const BG &a);
00105     BG power(double y) const {BG r = exp(y*log(*this)); return r;}
00106 
00107     friend double fabs(const BG &a){return std::fabs(a.f);};
00108 
00109     void NRupdate(void);
00110 
00111     void display(void);
00112 
00113     friend std::ostream& operator<<(std::ostream &os, const BG &a){
00114       os << a.f ; 
00115       return os;
00116     }
00117 
00118 
00119   };
00120 
00121  inline void initial_BGarray( BG *v, unsigned n, double a) {
00122   for (unsigned i = 0; i<n; i++) {
00123      v[i] = a;
00124   }
00125 }
00126 
00127 }  ///////// end of namespace matvec
00128 #endif  

Generated on Thu Jun 16 17:13:37 2005 for Matvec by doxygen1.2.16