vecutl.cpp

Go to the documentation of this file.
00001 #include "vecbse.h"
00002 #include "bnengine.h"
00003 //
00004 //********************************************************************************
00005 //                  UTILITY  MEMBER_FUNCTIONS
00006 //********************************************************************************
00007 //
00008 //
00009 // Routines return double. When adding multiple data types, I'll
00010 // need to promote the utilities to the derived classes so that
00011 // they can return the appropriate type.
00012 //
00013 double  CAMvectorBase::max() const
00014 {
00015 //
00016 //  Need Conversion Check
00017 //
00018     CAMvectorBase A;
00019     double* AdataP;
00020     long    n;
00021     double  value;
00022 
00023     if(A.Structure.isSubset() == 1)
00024     {
00025     A.initializeMinDuplicate(*this);
00026     AdataP = (double*)A.getDataPointer();
00027     n      = A.Structure.getFullDataCount();
00028     }
00029     else
00030     {
00031     AdataP = (double*)getDataPointer();
00032     n      = Structure.getFullDataCount();
00033     }
00034 
00035     CAMbinaryEngine::doubleMaxValue(AdataP, n, value);
00036     return value;
00037 }
00038 
00039 double  CAMvectorBase::min() const
00040 {
00041 //
00042 //  Need Conversion Check
00043 //
00044     CAMvectorBase A;
00045     double* AdataP;
00046     long n;
00047     double  value;
00048 
00049     if(A.Structure.isSubset() == 1)
00050     {
00051     A.initializeMinDuplicate(*this);
00052     AdataP = (double*)A.getDataPointer();
00053     n      = A.Structure.getFullDataCount();
00054     }
00055     else
00056     {
00057     AdataP = (double*)getDataPointer();
00058     n      = Structure.getFullDataCount();
00059     }
00060 
00061     CAMbinaryEngine::doubleMinValue(AdataP, n, value);
00062     return value;
00063 }
00064 
00065 double  CAMvectorBase::maxAbs() const
00066 {
00067 //
00068 //  Need Conversion Check
00069 //
00070     CAMvectorBase A;
00071     double* AdataP;
00072     long n;
00073     double  value;
00074 
00075     if(A.Structure.isSubset() == 1)
00076     {
00077     A.initializeMinDuplicate(*this);
00078     AdataP = (double*)A.getDataPointer();
00079     n      = A.Structure.getFullDataCount();
00080     }
00081     else
00082     {
00083     AdataP = (double*)getDataPointer();
00084     n      = Structure.getFullDataCount();
00085     }
00086 
00087     CAMbinaryEngine::doubleMaxAbsValue(AdataP, n, value);
00088     return value;
00089 }
00090 
00091 double  CAMvectorBase::minAbs() const
00092 {
00093 //
00094 //  Need Conversion Check
00095 //
00096     CAMvectorBase A;
00097     double* AdataP;
00098     long n;
00099     double  value;
00100 
00101     if(A.Structure.isSubset() == 1)
00102     {
00103     A.initializeMinDuplicate(*this);
00104     AdataP = (double*)A.getDataPointer();
00105     n      = A.Structure.getFullDataCount();
00106     }
00107     else
00108     {
00109     AdataP = (double*)getDataPointer();
00110     n      = Structure.getFullDataCount();
00111     }
00112 
00113     CAMbinaryEngine::doubleMinAbsValue(AdataP, n, value);
00114     return value;
00115 }
00116 
00117 
00118 double  CAMvectorBase::infNorm() const
00119 {
00120 //
00121 //  Need Conversion Check
00122 //
00123     CAMvectorBase A;
00124     double* AdataP;
00125     long    n;
00126     double  value;
00127 
00128     if(A.Structure.isSubset() == 1)
00129     {
00130     A.initializeMinDuplicate(*this);
00131     AdataP = (double*)A.getDataPointer();
00132     n      = A.Structure.getFullDataCount();
00133     }
00134     else
00135     {
00136     AdataP = (double*)getDataPointer();
00137     n      = Structure.getFullDataCount();
00138     }
00139 
00140     CAMbinaryEngine::doubleMaxAbsValue(AdataP, n, value);
00141     return value;
00142 }
00143 
00144 double  CAMvectorBase::pNorm(double p) const
00145 {
00146 //
00147 //  Need Conversion Check
00148 //
00149     CAMvectorBase A;
00150     double* AdataP;
00151     long    n;
00152     double  value;
00153 
00154     if(A.Structure.isSubset() == 1)
00155     {
00156     A.initializeMinDuplicate(*this);
00157     AdataP = (double*)A.getDataPointer();
00158     n      = A.Structure.getFullDataCount();
00159     }
00160     else
00161     {
00162     AdataP = (double*)getDataPointer();
00163     n      = Structure.getFullDataCount();
00164     }
00165 
00166     CAMbinaryEngine::doublepNorm(AdataP, n, p, value);
00167     return value;
00168 }
00169 
00170 double  CAMvectorBase::pNorm(int p) const {return pNorm(double(p));}
00171 double  CAMvectorBase::pNorm(long p) const {return pNorm(double(p));}
00172 double  CAMvectorBase::pNorm(float p) const {return pNorm(double(p));}
00173 double CAMvectorBase::dot(const CAMvectorBase& V) const
00174 {
00175 //
00176 //  Need Conversion Check
00177 //
00178 
00179    if(Structure.isConformingTo(V.Structure) != 1)
00180    {CAMvectorBase::nonConformingMessage(Structure,V.Structure);}
00181 
00182     long M;
00183 
00184     CAMvectorBase A;
00185     double* AdataPtr;
00186 
00187     CAMvectorBase Vb;
00188     double* VdataPtr;
00189     long    Vcount;
00190 
00191     if(Structure.isSubset() == 1)
00192     {
00193     A.initializeMinDuplicate(*this);
00194     AdataPtr    = (double*)A.getDataPointer();
00195     M = A.getIndexCount();
00196     }
00197     else
00198     {
00199     AdataPtr  = (double*)getDataPointer();
00200     M = getIndexCount();
00201     }
00202 
00203     if(V.Structure.isSubset() == 1)
00204     {
00205     Vb.initializeMinDuplicate(V);
00206     VdataPtr    = (double*)Vb.getDataPointer();
00207     }
00208     else
00209     {
00210     VdataPtr    = (double*)V.getDataPointer();
00211     }
00212 
00213    double sum = 0.0;
00214    long i;
00215    for(i = 0; i < M; i++)
00216    {
00217    sum += (*(VdataPtr + i))*(*(AdataPtr + i));
00218    }
00219    return sum;
00220 }
00221 //
00222 //********************************************************************************
00223 //                     CPP File End
00224 //********************************************************************************
00225 //
00226 
00227   

Generated on Wed Aug 6 12:58:55 2003 for Open-Sessame Framework by doxygen1.3