TCernLib.h

Go to the documentation of this file.
00001 // @(#)root/table:$Id: TCernLib.h 20882 2007-11-19 11:31:26Z rdm $
00002 // Author: Valery Fine(fine@bnl.gov)   25/09/99
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #ifndef ROOT_TCernLib
00013 #define ROOT_TCernLib
00014 
00015 #include "Rtypes.h"
00016 #include <string.h>
00017 
00018 // http://wwwinfo.cern.ch/asdoc/shortwrupsdir/f110/top.html
00019 
00020 ///////////////////////////////////////////////////////////////////////////////////////
00021 //                                                                                   //
00022 // The routines of MXPACK compute the product of two matrices or the product of      //
00023 // their transposed matrices and may add or subtract to the resultant matrix         //
00024 // a third one, add or subtract one matrix from another, or transfer a matrix,       //
00025 // its negative, or a multiple of it, transpose a given matrix, build up a unit      //
00026 // matrix, multiply a matrix by a diagonal (from left or from right) and may         //
00027 // add the result to another matrix, add to square matrix the multiple of a diagonal //
00028 // matrix, compute the products <IMG WIDTH=79 HEIGHT=12 ALIGN=BOTTOM ALT="tex2html_wrap_inline191" SRC="gif/mxpack_ABAt.gif"> (<IMG WIDTH=16 HEIGHT=12 ALIGN=BOTTOM ALT="tex2html_wrap_inline193" SRC="gif/mxpack_At.gif"> denotes the transpose of <IMG WIDTH=1
00029 // It is assumed that matrices are begin_html <B>row-wise without gaps</B> end_html without gaps.                     //
00030 //                                                                                   //
00031 ///////////////////////////////////////////////////////////////////////////////////////
00032 
00033 class TArrayD;
00034 
00035 class TCL  {
00036 public:
00037    virtual ~TCL() { }
00038 
00039    static int    *ucopy(const int    *a, int    *b, int n);
00040    static float  *ucopy(const float  *a, float  *b, int n);
00041    static double *ucopy(const float  *a, double *b, int n);
00042    static float  *ucopy(const double *a, float  *b, int n);
00043    static double *ucopy(const double *a, double *b, int n);
00044    static void  **ucopy(const void **a, void  **b, int n);
00045 
00046    static float  *vzero(float *a,  int n2);
00047    static double *vzero(double *a, int n2);
00048    static void  **vzero(void **a,  int n2);
00049 
00050    static float  *vadd(const float *b,  const float  *c,  float *a, int n);
00051    static double *vadd(const double *b, const double *c, double *a, int n);
00052 
00053    static float  *vadd(const float *b,  const double *c, float *a, int n);
00054    static double *vadd(const double *b, const float  *c,double *a, int n);
00055 
00056    static float   vdot(const float  *b, const float  *a, int n);
00057    static double  vdot(const double *b, const double *a, int n);
00058 
00059    static float  *vsub(const float  *a, const float  *b, float  *x, int n);
00060    static double *vsub(const double *a, const double *b, double *x, int n);
00061    static float  *vsub(const float  *b, const double *c, float  *a, int n);
00062    static double *vsub(const double *b, const float  *c, double *a, int n);
00063 
00064    static float  *vcopyn(const float *a,  float *x, int n);
00065    static double *vcopyn(const double *a, double *x, int n);
00066 
00067    static float  *vscale(const float  *a, float  scale, float  *b, int n);
00068    static double *vscale(const double *a, double scale, double *b, int n);
00069 
00070    static float  *vlinco(const float  *a, float  fa, const float  *b, float  fb,float  *x, int n);
00071    static double *vlinco(const double *a, double fa, const double *b, double fb,double *x, int n);
00072 
00073    static float  *vmatl(const float  *g, const float  *c, float  *x, int n=3,int m=3);
00074    static double *vmatl(const double *g, const double *c, double *x, int n=3,int m=3);
00075 
00076    static float  *vmatr(const float  *c, const float  *g, float  *x, int n=3,int m=3);
00077    static double *vmatr(const double *c, const double *g, double *x, int n=3,int m=3);
00078 
00079    static float *mxmad_0_(int n, const float *a, const float *b, float *c, int i, int j, int k);
00080 
00081    static float *mxmad( const float *a, const float *b, float *c, int i, int j, int k);
00082    static float *mxmad1(const float *a, const float *b, float *c, int i, int j, int k);
00083    static float *mxmad2(const float *a, const float *b, float *c, int i, int j, int k);
00084    static float *mxmad3(const float *a, const float *b, float *c, int i, int j, int k);
00085    static float *mxmpy( const float *a, const float *b, float *c, int i, int j, int k);
00086    static float *mxmpy1(const float *a, const float *b, float *c, int i, int j, int k);
00087    static float *mxmpy2(const float *a, const float *b, float *c, int i, int j, int k);
00088    static float *mxmpy3(const float *a, const float *b, float *c, int i, int j, int k);
00089    static float *mxmub( const float *a, const float *b, float *c, int i, int j, int k);
00090    static float *mxmub1(const float *a, const float *b, float *c, int i, int j, int k);
00091    static float *mxmub2(const float *a, const float *b, float *c, int i, int j, int k);
00092    static float *mxmub3(const float *a, const float *b, float *c, int i, int j, int k);
00093 
00094    static float *mxmlrt_0_(int n__, const float *a, const float *b, float *c, int ni,int nj);
00095    static float *mxmlrt(const float *a, const float *b, float *c, int ni, int nj);
00096    static float *mxmltr(const float *a, const float *b, float *c, int ni, int nj);
00097    static float *mxtrp(const float *a, float *b, int i, int j);
00098 
00099    static double *mxmad_0_(int n, const double *a, const double *b, double *c, int i, int j, int k);
00100 
00101    static double *mxmad (const double *a, const double *b, double *c, int i, int j, int k);
00102    static double *mxmad1(const double *a, const double *b, double *c, int i, int j, int k);
00103    static double *mxmad2(const double *a, const double *b, double *c, int i, int j, int k);
00104    static double *mxmad3(const double *a, const double *b, double *c, int i, int j, int k);
00105    static double *mxmpy (const double *a, const double *b, double *c, int i, int j, int k);
00106    static double *mxmpy1(const double *a, const double *b, double *c, int i, int j, int k);
00107    static double *mxmpy2(const double *a, const double *b, double *c, int i, int j, int k);
00108    static double *mxmpy3(const double *a, const double *b, double *c, int i, int j, int k);
00109    static double *mxmub (const double *a, const double *b, double *c, int i, int j, int k);
00110    static double *mxmub1(const double *a, const double *b, double *c, int i, int j, int k);
00111    static double *mxmub2(const double *a, const double *b, double *c, int i, int j, int k);
00112    static double *mxmub3(const double *a, const double *b, double *c, int i, int j, int k);
00113 
00114    static double *mxmlrt_0_(int n__, const double *a, const double *b, double *c, int ni,int nj);
00115    static double *mxmlrt(const double *a, const double *b, double *c, int ni, int nj);
00116    static double *mxmltr(const double *a, const double *b, double *c, int ni, int nj);
00117    static double *mxtrp(const double *a, double *b, int i, int j);
00118 
00119 // * TR pack
00120 
00121    static float *traat(const float *a, float *s, int m, int n);
00122    static float *tral(const float *a, const float *u, float *b, int m, int n);
00123    static float *tralt(const float *a, const float *u, float *b, int m, int n);
00124    static float *tras(const float *a, const float *s, float *b, int m, int n);
00125    static float *trasat(const float *a, const float *s, float *r, int m, int n);
00126    static float *trasat(const double *a, const float *s, float *r, int m, int n);
00127    static float *trata(const float *a, float *r, int m, int n);
00128    static float *trats(const float *a, const float *s, float *b, int m, int n);
00129    static float *tratsa(const float *a, const float *s, float *r, int m, int n);
00130    static float *trchlu(const float *a, float *b, int n);
00131    static float *trchul(const float *a, float *b, int n);
00132    static float *trinv(const float *t, float *s, int n);
00133    static float *trla(const float *u, const float *a, float *b, int m, int n);
00134    static float *trlta(const float *u, const float *a, float *b, int m, int n);
00135    static float *trpck(const float *s, float *u, int n);
00136    static float *trqsq(const float *q, const float *s, float *r, int m);
00137    static float *trsa(const float *s, const float *a, float *b, int m, int n);
00138    static float *trsinv(const float *g, float *gi, int n);
00139    static float *trsmlu(const float *u, float *s, int n);
00140    static float *trsmul(const float *g, float *gi, int n);
00141    static float *trupck(const float *u, float *s, int m);
00142    static float *trsat(const float *s, const float *a, float *b, int m, int n);
00143 
00144 // Victor Perevoztchikov's addition:
00145    static float *trsequ(float *smx, int m=3, float *b=0, int n=1);
00146 
00147 // ---   double version
00148 
00149    static double *traat (const double *a, double *s, int m, int n);
00150    static double *tral  (const double *a, const double *u, double *b, int m, int n);
00151    static double *tralt (const double *a, const double *u, double *b, int m, int n);
00152    static double *tras  (const double *a, const double *s, double *b, int m, int n);
00153    static double *trasat(const double *a, const double *s, double *r, int m, int n);
00154    static double *trata (const double *a, double *r, int m, int n);
00155    static double *trats (const double *a, const double *s, double *b, int m, int n);
00156    static double *tratsa(const double *a, const double *s, double *r, int m, int n);
00157    static double *trchlu(const double *a, double *b, int n);
00158    static double *trchul(const double *a, double *b, int n);
00159    static double *trinv (const double *t, double *s, int n);
00160    static double *trla  (const double *u, const double *a, double *b, int m, int n);
00161    static double *trlta (const double *u, const double *a, double *b, int m, int n);
00162    static double *trpck (const double *s, double *u, int n);
00163    static double *trqsq (const double *q, const double *s, double *r, int m);
00164    static double *trsa  (const double *s, const double *a, double *b, int m, int n);
00165    static double *trsinv(const double *g, double *gi, int n);
00166    static double *trsmlu(const double *u, double *s, int n);
00167    static double *trsmul(const double *g, double *gi, int n);
00168    static double *trupck(const double *u, double *s, int m);
00169    static double *trsat (const double *s, const double *a, double *b, int m, int n);
00170 
00171 //  Victor Perevoztchikov's addition:
00172    static double *trsequ(double *smx, int m=3, double *b=0, int n=1);
00173 
00174    ClassDef(TCL,0)  //C++ replacement for CERNLIB matrix / triangle matrix packages: F110 and F112
00175 
00176 };
00177 
00178 //___________________________________________________________________________
00179 inline float *TCL::mxmad(const float *a, const float *b, float *c, int i, int j, int k)
00180 {
00181    // Begin_Html <P ALIGN=CENTER> <IMG SRC="gif/mxpack_mxmad.gif"> </P> End_Html //
00182    return mxmad_0_(0, a, b, c, i, j, k);   }
00183 
00184 //___________________________________________________________________________
00185 inline float *TCL::mxmad1(const float *a, const float *q, float *c, int i, int j, int k)
00186 {
00187    // Begin_Html <P ALIGN=CENTER> <IMG SRC="gif/mxpack_mxmad1.gif"> </P> End_Html //
00188    return mxmad_0_(1, a, q, c, i, j, k);  }
00189 
00190 //___________________________________________________________________________
00191 inline float *TCL::mxmad2(const float *p, const float *b, float *c, int i, int j, int k)
00192 {
00193    // Begin_Html <P ALIGN=CENTER> <IMG SRC="gif/mxpack_mxmad2.gif"> </P> End_Html //
00194    return mxmad_0_(2, p, b, c, i, j, k);  }
00195 
00196 //___________________________________________________________________________
00197 inline float *TCL::mxmad3(const float *p, const float *q, float *c, int i, int j, int k)
00198 {
00199    // Begin_Html <P ALIGN=CENTER> <IMG SRC="gif/mxpack_mxmad3.gif"> </P> End_Html //
00200    return mxmad_0_(3, p, q, c, i, j, k);  }
00201 
00202 //___________________________________________________________________________
00203 inline float *TCL::mxmpy(const float *a, const float *b, float *c, int i, int j, int k)
00204 {
00205    // Begin_Html <P ALIGN=CENTER> <IMG SRC="gif/mxpack_mxmpy.gif"> </P> End_Html //
00206    return mxmad_0_(4, a, b, c, i, j, k); }
00207 
00208 //___________________________________________________________________________
00209 inline float *TCL::mxmpy1(const float *a, const float *q, float *c, int i, int j, int k)
00210 {
00211    // Begin_Html <P ALIGN=CENTER> <IMG SRC="gif/mxpack_mxmpy1.gif"> </P> End_Html //
00212    return mxmad_0_(5, a, q, c, i, j, k);  }
00213 
00214 //___________________________________________________________________________
00215 inline float *TCL::mxmpy2(const float *p, const float *b, float *c, int i, int j, int k)
00216 {
00217    // Begin_Html <P ALIGN=CENTER> <IMG SRC="gif/mxpack_mxmpy2.gif"> </P> End_Html //
00218    return mxmad_0_(6, p, b, c, i, j, k); }
00219 
00220 //___________________________________________________________________________
00221 inline float *TCL::mxmpy3(const float *p, const float *q, float *c, int i, int j, int k)
00222 {
00223    // Begin_Html <P ALIGN=CENTER> <IMG SRC="gif/mxpack_mxmpy3.gif"> </P> End_Html //
00224    return mxmad_0_(7, p, q, c, i, j, k); }
00225 
00226 //___________________________________________________________________________
00227 inline float *TCL::mxmub(const float *a, const float *b, float *c, int i, int j, int k)
00228 {
00229    // Begin_Html <P ALIGN=CENTER> <IMG SRC="gif/mxpack_mxmub.gif"> </P> End_Html //
00230    return mxmad_0_(8, a, b, c, i, j, k);  }
00231 
00232 //___________________________________________________________________________
00233 inline float *TCL::mxmub1(const float *a, const float *q, float *c, int i, int j, int k)
00234 {
00235    // Begin_Html <P ALIGN=CENTER> <IMG SRC="gif/mxpack_mxmub1.gif"> </P> End_Html //
00236    return mxmad_0_(9, a, q, c, i, j, k); }
00237 
00238 //___________________________________________________________________________
00239 inline float *TCL::mxmub2(const float *p, const float *b, float *c, int i, int j, int k)
00240 {
00241    // Begin_Html <P ALIGN=CENTER> <IMG SRC="gif/mxpack_mxmub2.gif"> </P> End_Html //
00242    return mxmad_0_(10, p, b, c, i, j, k); }
00243 
00244 //___________________________________________________________________________
00245 inline float *TCL::mxmub3(const float *p, const float *q, float *c, int i, int j, int k)
00246 {
00247    // Begin_Html <P ALIGN=CENTER> <IMG SRC="gif/mxpack_mxmub3.gif"> </P> End_Html //
00248    return mxmad_0_(11, p, q, c, i, j, k); }
00249 
00250 //___________________________________________________________________________
00251 inline float *TCL::mxmlrt(const float *a, const float *b, float *x, int ni, int nj)
00252 {
00253    // Begin_Html <P ALIGN=CENTER> <IMG SRC="gif/mxpack_mxmlrt.gif"> </P> End_Html //
00254    return mxmlrt_0_(0, a, b, x, ni, nj); }
00255 
00256 //___________________________________________________________________________
00257 inline float *TCL::mxmltr(const float *a, const float *b, float *x, int ni, int nj)
00258 {
00259    // Begin_Html <P ALIGN=CENTER> <IMG SRC="gif/mxpack_mxmltr.gif"> </P> End_Html //
00260    return mxmlrt_0_(1, a, b, x, ni, nj);   }
00261 
00262 
00263 //--   double version --
00264 
00265 //___________________________________________________________________________
00266 inline double *TCL::mxmad(const double *a, const double *b, double *c, int i, int j, int k)
00267 {
00268    // Begin_Html <P ALIGN=CENTER> <IMG SRC="gif/mxpack_mxmad.gif"> </P> End_Html //
00269    return mxmad_0_(0, a, b, c, i, j, k);   }
00270 
00271 //___________________________________________________________________________
00272 inline double *TCL:: mxmad1(const double *a, const double *b, double *c, int i, int j, int k)
00273 {
00274    // Begin_Html <P ALIGN=CENTER> <IMG SRC="gif/mxpack_mxmad.gif"> </P> End_Html //
00275    return mxmad_0_(1, a, b, c, i, j, k);  }
00276 
00277 //___________________________________________________________________________
00278 inline double *TCL::mxmad2(const double *a, const double *b, double *c, int i, int j, int k)
00279 {
00280    // Begin_Html <P ALIGN=CENTER> <IMG SRC="gif/mxpack_mxmad.gif"> </P> End_Html //
00281    return mxmad_0_(2, a, b, c, i, j, k);  }
00282 
00283 //___________________________________________________________________________
00284 inline double *TCL::mxmad3(const double *a, const double *b, double *c, int i, int j, int k)
00285 {
00286    // Begin_Html <P ALIGN=CENTER> <IMG SRC="gif/mxpack_mxmad.gif"> </P> End_Html //
00287    return mxmad_0_(3, a, b, c, i, j, k);  }
00288 
00289 //___________________________________________________________________________
00290 inline double *TCL::mxmpy(const double *a, const double *b, double *c, int i, int j, int k)
00291 {
00292    // Begin_Html <P ALIGN=CENTER> <IMG SRC="gif/mxpack_mxmad.gif"> </P> End_Html //
00293    return mxmad_0_(4, a, b, c, i, j, k); }
00294 
00295 //___________________________________________________________________________
00296 inline double *TCL::mxmpy1(const double *a, const double *b, double *c, int i, int j, int k)
00297 {
00298    // Begin_Html <P ALIGN=CENTER> <IMG SRC="gif/mxpack_mxmad.gif"> </P> End_Html //
00299    return mxmad_0_(5, a, b, c, i, j, k);  }
00300 
00301 //___________________________________________________________________________
00302 inline double *TCL::mxmpy2(const double *a, const double *b, double *c, int i, int j, int k)
00303 {
00304    // Begin_Html <P ALIGN=CENTER> <IMG SRC="gif/mxpack_mxmad.gif"> </P> End_Html //
00305    return mxmad_0_(6, a, b, c, i, j, k); }
00306 
00307 //___________________________________________________________________________
00308 inline double *TCL::mxmpy3(const double *a, const double *b, double *c, int i, int j, int k)
00309 {
00310    // Begin_Html <P ALIGN=CENTER> <IMG SRC="gif/mxpack_mxmad.gif"> </P> End_Html //
00311    return mxmad_0_(7, a, b, c, i, j, k); }
00312 
00313 //___________________________________________________________________________
00314 inline double *TCL::mxmub(const double *a, const double *b, double *c, int i, int j, int k)
00315 {
00316    // Begin_Html <P ALIGN=CENTER> <IMG SRC="gif/mxpack_mxmad.gif"> </P> End_Html //
00317    return mxmad_0_(8, a, b, c, i, j, k);  }
00318 
00319 //___________________________________________________________________________
00320 inline double *TCL::mxmub1(const double *a, const double *b, double *c, int i, int j, int k)
00321 {
00322    // Begin_Html <P ALIGN=CENTER> <IMG SRC="gif/mxpack_mxmad.gif"> </P> End_Html //
00323    return mxmad_0_(9, a, b, c, i, j, k); }
00324 
00325 //___________________________________________________________________________
00326 inline double *TCL::mxmub2(const double *a, const double *b, double *c, int i, int j, int k)
00327 {
00328    // Begin_Html <P ALIGN=CENTER> <IMG SRC="gif/mxpack_mxmad.gif"> </P> End_Html //
00329    return mxmad_0_(10, a, b, c, i, j, k); }
00330 
00331 //___________________________________________________________________________
00332 inline double *TCL::mxmub3(const double *a, const double *b, double *c, int i, int j, int k)
00333 {
00334    // Begin_Html <P ALIGN=CENTER> <IMG SRC="gif/mxpack_mxmad.gif"> </P> End_Html //
00335    return mxmad_0_(11, a, b, c, i, j, k); }
00336 
00337 //___________________________________________________________________________
00338 inline double *TCL::mxmlrt(const double *a, const double *b, double *c, int ni, int nj)
00339 {
00340    // Begin_Html <P ALIGN=CENTER> <IMG SRC="gif/mxpack_mxmad.gif"> </P> End_Html //
00341    return  mxmlrt_0_(0, a, b, c, ni, nj); }
00342 
00343 //___________________________________________________________________________
00344 inline double *TCL::mxmltr(const double *a, const double *b, double *c, int ni, int nj)
00345 {
00346    // Begin_Html <P ALIGN=CENTER> <IMG SRC="gif/mxpack_mxmad.gif"> </P> End_Html //
00347    return mxmlrt_0_(1, a, b, c, ni, nj);   }
00348 
00349 // ----
00350 
00351 //________________________________________________________
00352 inline int  *TCL::ucopy(const int  *b, int  *a, int n)
00353 {
00354    //to be documented
00355    if (n <= 0) return 0; memcpy(a,b,n*sizeof(int)); return a;
00356 }
00357 
00358 //________________________________________________________
00359 inline float *TCL::ucopy(const float *b, float *a, int n)
00360 {
00361    //to be documented
00362    if (n <= 0) return 0; memcpy(a,b,n*sizeof(float)); return a;
00363 }
00364 
00365 //________________________________________________________
00366 inline float *TCL::ucopy(const double *b, float *a, int n)
00367 {
00368    //to be documented
00369    if (n <= 0) return 0;
00370    for (int i=0;i<n;i++,a++,b++) *a = float(*b);
00371    return a;
00372 }
00373 
00374 //________________________________________________________
00375 inline double *TCL::ucopy(const float *b, double *a, int n)
00376 {
00377    //to be documented
00378    if (n <= 0) return 0;
00379    for (int i=0;i<n;i++,a++,b++) *a = double(*b);
00380    return a;
00381 }
00382 
00383 //________________________________________________________
00384 inline double *TCL::ucopy(const double *b, double *a, int n)
00385 {
00386    //to be documented
00387    if (n <= 0) return 0; memcpy(a,b,n*sizeof(double)); return a;
00388 }
00389 
00390 //________________________________________________________
00391 inline void **TCL::ucopy(const void **b, void  **a, int n)
00392 {
00393    //to be documented
00394    if (n <= 0) return 0; memcpy(a,b,n*sizeof(void *)); return a;
00395 }
00396 
00397 
00398 //________________________________________________________
00399 inline float *TCL::vadd(const float *b, const float *c,  float *a, int n)
00400 {
00401    //to be documented
00402    if (n <= 0)  return 0;
00403    for (int i=0;i<n;i++) a[i] = b[i] + c[i];
00404    return a;
00405 }
00406 
00407 //________________________________________________________
00408 inline double *TCL::vadd(const double *b, const double *c,  double *a, int n)
00409 {
00410    //to be documented
00411    if (n <= 0)  return 0;
00412    for (int i=0;i<n;i++) a[i] = b[i] + c[i];
00413    return a;
00414 }
00415 
00416 //________________________________________________________
00417 inline float  *TCL::vadd(const float *b, const double *c,  float *a, int n)
00418 {
00419    //to be documented
00420    if (n <= 0)  return 0;
00421    for (int i=0;i<n;i++) a[i] = b[i] + c[i];
00422    return a;
00423 }
00424 
00425 //________________________________________________________
00426 inline double *TCL::vadd(const double *b, const float *c,  double *a, int n)
00427 {
00428    //to be documented
00429    if (n <= 0)  return 0;
00430    for (int i=0;i<n;i++) a[i] = b[i] + c[i];
00431    return a;
00432 }
00433 
00434 //________________________________________________________
00435 inline float  TCL::vdot(const float  *b, const float *a, int n)
00436 {
00437    //to be documented
00438    float x=0;
00439    if (n>0)
00440       for (int i=0;i<n;i++,a++,b++) x += (*a) * (*b);
00441    return x;
00442 }
00443 //________________________________________________________
00444 inline double TCL::vdot(const double *b, const double *a, int n)
00445 {
00446    //to be documented
00447    double  x=0;
00448    if (n>0)
00449       for (int i=0;i<n;i++,a++,b++) x += (*a) * (*b);
00450    return x;
00451 }
00452 //________________________________________________________
00453 inline float *TCL::vsub(const float *a, const float *b, float *x, int n)
00454 {
00455    //to be documented
00456    if (n <= 0) return 0;
00457    for (int i=0;i<n;i++) x[i] = a[i]-b[i];
00458    return x;
00459 }
00460 
00461 //________________________________________________________
00462 inline double *TCL::vsub(const double *a, const double *b, double *x, int n)
00463 {
00464   //to be documented
00465    if (n <= 0) return 0;
00466    for (int i=0;i<n;i++) x[i] = a[i]-b[i];
00467    return x;
00468 }
00469 //________________________________________________________
00470 inline float  *TCL::vsub(const float *b, const double *c,  float *a, int n)
00471 {
00472    //to be documented
00473    if (n <= 0)  return 0;
00474    for (int i=0;i<n;i++) a[i] = b[i] - c[i];
00475    return a;
00476 }
00477 
00478 //________________________________________________________
00479 inline double *TCL::vsub(const double *b, const float *c,  double *a, int n)
00480 {
00481    //to be documented
00482    if (n <= 0)  return 0;
00483    for (int i=0;i<n;i++) a[i] = b[i] - c[i];
00484    return a;
00485 }
00486 //________________________________________________________
00487 inline float *TCL::vcopyn(const float *a, float *x, int n)
00488 {
00489    //to be documented
00490    if (n <= 0) return 0;
00491    for (int i=0;i<n;i++) x[i] = -a[i];
00492    return x;
00493 }
00494 //________________________________________________________
00495 inline double *TCL::vcopyn(const double *a, double *x, int n)
00496 {
00497    //to be documented
00498    if (n <= 0) return 0;
00499    for (int i=0;i<n;i++) x[i] = -a[i];
00500    return x;
00501 }
00502 
00503 //________________________________________________________
00504 inline float *TCL::vzero(float *a, int n1)
00505 {
00506    //to be documented
00507    if (n1 <= 0) return 0;
00508    return (float *)memset(a,0,n1*sizeof(float));
00509 }
00510 
00511 //________________________________________________________
00512 inline double *TCL::vzero(double *a, int n1)
00513 {
00514    //to be documented
00515    if (n1 <= 0) return 0;
00516    return (double *)memset(a,0,n1*sizeof(double));
00517 }
00518 
00519 //________________________________________________________
00520 inline void **TCL::vzero(void **a, int n1)
00521 {
00522    //to be documented
00523    if (n1 <= 0) return 0;
00524    return (void **)memset(a,0,n1*sizeof(void *));
00525 }
00526 
00527 //________________________________________________________
00528 inline float *TCL::vscale(const float *a, float scale, float *b, int n)
00529 {
00530    //to be documented
00531    for (int i=0;i<n;i++) b[i]=scale*a[i];
00532    return b;
00533 }
00534 
00535 //________________________________________________________
00536 inline double *TCL::vscale(const double *a, double scale, double *b, int n)
00537 {
00538    //to be documented
00539    for (int i=0;i<n;i++) b[i]=scale*a[i];
00540    return b;
00541 }
00542 
00543 //________________________________________________________
00544 inline float *TCL::vlinco(const float *a, float fa, const float *b, float fb, float *x, int n)
00545 {
00546    //to be documented
00547    for (int i=0;i<n;i++){x[i]=a[i]*fa+b[i]*fb;};
00548    return x;
00549 }
00550 
00551 //________________________________________________________
00552 inline double *TCL::vlinco(const double *a, double fa, const double *b, double fb,double *x, int n)
00553 {
00554    //to be documented
00555    for (int i=0;i<n;i++) x[i]=a[i]*fa+b[i]*fb;
00556    return x;
00557 }
00558 
00559 //_____________________________________________________________________________
00560 inline float *TCL::vmatl(const float *G, const float *c, float *x, int n,int m)
00561 {
00562    //  x = G*c
00563    for (int i=0; i<n; i++) {
00564       double sum = 0;
00565       for (int j=0; j<m; j++) sum += G[j + m*i]*c[j];
00566       x[i] = sum;
00567    }
00568    return x;
00569 }
00570 
00571 //_____________________________________________________________________________
00572 inline double *TCL::vmatl(const double *G, const double *c, double *x, int n,int m)
00573 {
00574    //  x = G*c
00575    for (int i=0; i<n; i++) {
00576       double sum = 0;
00577       for (int j=0; j<m; j++) sum += G[j + m*i]*c[j];
00578       x[i] = sum;
00579    }
00580    return x;
00581 }
00582 
00583 //_____________________________________________________________________________
00584 inline float *TCL::vmatr(const float *c, const float *G, float *x, int n,int m)
00585 {
00586    //  x = c*G
00587    for (int j=0; j<m; j++) {
00588       double sum = 0;
00589       for (int i=0; i<n; i++) sum += G[j + n*i]*c[i];
00590       x[j] = sum;
00591    }
00592    return x;
00593 }
00594 
00595 //_____________________________________________________________________________
00596 inline double *TCL::vmatr(const double *c, const double *G, double *x, int n,int m)
00597 {
00598    //  x = c*G
00599    for (int j=0; j<m; j++) {
00600       double sum = 0;
00601       for (int i=0; i<n; i++) sum += G[j + n*i]*c[i];
00602       x[j] = sum;
00603    }
00604    return x;
00605 }
00606 
00607 #endif

Generated on Tue Jul 5 14:26:38 2011 for ROOT_528-00b_version by  doxygen 1.5.1