mmx::vct Namespace Reference

Functions


Function Documentation

void mmx::vct::accconv ( C *  r,
int  str,
const C *  a,
unsigned  na,
int  sta,
const C *  b,
unsigned  nb,
int  stb 
) [inline]

standard convolution loop, do not initialize r.

Parameters:
r base address of the result.
str increment for r.
a base address of first operand.
na number of coefficients for a.
sta increment for a.
b base address of second operand.
nb number of coefficients for a.
stb increment for b.

Definition at line 277 of file tensor_vctops.hpp.

References C.

Referenced by conv().

00280   {
00281     C * er;
00282     const C * ea, * eb;
00283     for ( ea = a; ea != a + na*sta; ea += sta, r += str )
00284       for ( er = r, eb = b; eb != b + nb*stb; eb += stb, er += str )
00285         *er += *ea**eb;
00286   };

void mmx::vct::accmax ( A &  mx,
const B *  v,
unsigned  n,
int  s = 1 
) [inline]

Definition at line 192 of file tensor_vctops.hpp.

Referenced by max().

00193   {
00194     const B * p;
00195     for (  p = v; p != v+n*s; p += s )
00196       if ( mx < *p ) mx = *p;
00197   };

void mmx::vct::accmin ( A &  mn,
B const *  v,
unsigned  n,
int  s = 1 
) [inline]

Definition at line 177 of file tensor_vctops.hpp.

Referenced by min().

00178   {
00179     const B * p;
00180     for ( p = v; p != v + n*s; p += s ) 
00181       if ( mn > *p ) mn = *p;
00182   };

void mmx::vct::conv ( C *  r,
int  str,
const C *  a,
unsigned  na,
int  sta,
const C *  b,
unsigned  nb,
int  stb 
) [inline]

standard convolution loop.

Parameters:
r base address of the result.
str increment for r.
a base address of first operand.
na number of coefficients for a.
sta increment for a.
b base address of second operand.
nb number of coefficients for a.
stb increment for b.

Definition at line 300 of file tensor_vctops.hpp.

References accconv(), and C.

00303   {
00304     C * er;
00305     for ( er = r; er != r + (na+nb-1)*str; *er++ = 0 ) ;
00306     accconv(r,str,a,na,sta,b,nb,stb);
00307   };

void mmx::vct::conv ( C *  r,
unsigned  nr,
int  str,
const C *  a,
unsigned  na,
int  sta,
const C *  b,
unsigned  nb,
int  stb 
) [inline]

truncated convolution loop:

Parameters:
r base address of the result.
nr number of coefficients wanted.
str increment for r.
a base address of first operand.
na number of coefficients for a.
sta increment for a.
b base address of second operand.
nb number of coefficients for a.
stb increment for b.

Definition at line 229 of file tensor_vctops.hpp.

References C, and min().

00237   {
00238     if ( na < nb ) { conv(r,nr,str,b,nb,stb,a,na,sta); return; };
00239     int k, l;
00240     C * er;
00241     const C * ea, * eb, * eeb, * eea;
00242     er = r; 
00243     eb = b;
00244     
00245     for ( er = r, eb = b, k = 0; k < std::min(nb,nr); k ++, er += str, eb += stb )
00246       for ( eeb = eb, ea = a, *er = 0, l = 0; 
00247             l <= k; 
00248             *er += *ea**eeb, l ++, eeb -= stb, ea += sta ) ;
00249     
00250     for ( ; k < std::min(na,nr) ; k ++,   er += str )
00251       for ( *er = 0, 
00252               l = k-nb+1, eeb = b +(nb-1)*stb , ea = a + l*sta; 
00253             l <= k; 
00254             *er+= *ea**eeb,
00255               l ++, eeb -= stb, ea += sta ) ;
00256     
00257     for ( ; k < nr; k ++,  er += str )
00258       for ( *er = 0, 
00259               l = k-nb+1, eeb = b+(nb-1)*stb,  ea = a + l*sta; 
00260             l < na; 
00261             *er += *ea**eeb, 
00262               l ++, eeb -= stb, ea += sta ) ;
00263   };

void mmx::vct::copy ( A *  a,
const B *  b,
unsigned  n,
int  sa,
int  sb 
) [inline]

Definition at line 146 of file tensor_vctops.hpp.

00147   {
00148     for ( A * ea = a; ea != a + n*sa; *ea = *b, ea += sa, b += sb ) ;
00149   };

void mmx::vct::copy ( A *  a,
const B *  b,
unsigned  n 
) [inline]

Definition at line 140 of file tensor_vctops.hpp.

Referenced by mmx::tensor::binoms(), and mmerge().

00141   {
00142     std::copy(b,b+n,a) ;
00143   };

void mmx::vct::decasteljau ( C *  c,
unsigned  n,
const I &  i,
int  s = 1 
) [inline]

Definition at line 459 of file tensor_vctops.hpp.

References C.

00460 {
00461   C *ec, *p;
00462   for ( ec = c + (n-1)*s; ec != c; ec -= s )
00463     for ( p = c; p != ec; p += s )
00464       *p = (1.0-i)**p+i**(p+s) ;
00465 };

void mmx::vct::dhorner ( O &  p,
O &  dp,
C const *const   c,
unsigned  n,
const I &  t,
int  s = 1 
) [inline]

Definition at line 468 of file tensor_vctops.hpp.

00469 { 
00470   p = c[n-1], dp  = 0.0; 
00471   for ( int j = (n-2)*s; j >=0; dp=dp*t+p, p=p*t+c[j], j -= s ) ; 
00472 };

void mmx::vct::diff ( C *  dst,
C const *const   src,
unsigned  sz,
int  st = 1 
) [inline]

Definition at line 453 of file tensor_vctops.hpp.

00454 { 
00455   for ( unsigned i = 0; i < sz-1; dst[i*st] = (i+1)*src[(i+1)*st], i++ ) ; 
00456 };

void mmx::vct::fill ( C *  a,
unsigned  n,
int  s,
const C &  x 
) [inline]

Definition at line 152 of file tensor_vctops.hpp.

References C.

Referenced by binary_sleeve_subdivision< K >::barre(), mmx::tensor::clear(), mmx::realroot::fill_data(), mmx::linear::LUinverse(), mcrossp(), mdotp(), msimplify(), and pmmul().

00153   {
00154     for ( C * pa = a; pa != a+n*s; *pa = x, pa += s ) ;
00155   };

texp::sup<C,I>::T mmx::vct::hhorner ( C const *const   c,
unsigned  n,
const I &  i,
const I &  i0,
int  s = 1 
) [inline]

Definition at line 444 of file tensor_vctops.hpp.

References hhorner().

00445 { 
00446   typename texp::ringof<C,I>::T o(0);
00447   hhorner(o,c,n,i,i0,s) ; 
00448   return o; 
00449 };

void mmx::vct::hhorner ( O &  o,
C const *const   c,
unsigned  n,
const I &  i,
const I &  i0,
int  s = 1 
) [inline]

Definition at line 436 of file tensor_vctops.hpp.

Referenced by mmx::tensor::hevalm(), and hhorner().

00437 { 
00438   o = O(c[(n-1)*s]);
00439   for ( int p = (n-2)*s; p >= 0; o *= i, o +=  O(c[p])*i0, p -= s ) ; 
00440 };

texp::sup<C,I>::T mmx::vct::horner ( C const *const   c,
unsigned  n,
const I &  i,
int  s = 1 
) [inline]

Definition at line 428 of file tensor_vctops.hpp.

References horner().

00429 { 
00430   typename texp::ringof<C,I>::T o(0);
00431   horner(o,c,n,i,s); 
00432   return o; 
00433 };

void mmx::vct::horner ( O &  o,
C const *const   c,
unsigned  n,
const I &  i,
int  s = 1 
) [inline]

Definition at line 420 of file tensor_vctops.hpp.

Referenced by horner().

00421 { 
00422   o = O(0);
00423   for ( int p = (n-1)*s; p != 0; o +=  as<O>(c[p]), o *= i, p -= s ) ; 
00424   o+= as<O>(c[0]); 
00425 };

void mmx::vct::icopy ( A *  a,
unsigned *  aadd,
unsigned  nadd,
const B *  b 
) [inline]

Definition at line 158 of file tensor_vctops.hpp.

Referenced by mmx::tensor::add(), mmx::tensor::extend(), and mmx::tensor::sub().

00159   {
00160     for ( unsigned * ea = aadd; ea != aadd + nadd; a[*ea++] = *b++ ) ;
00161   };

void mmx::vct::inverses ( A *  a,
A *  ea 
) [inline]

Definition at line 476 of file tensor_vctops.hpp.

Referenced by mmx::tensor::ibinoms().

00476 { for ( ;a != ea; *a++ = 1/(*a) ) ; };

void mmx::vct::ipadd ( A *  a,
unsigned *  aadd,
unsigned  nadd,
const B *  b 
) [inline]

Definition at line 164 of file tensor_vctops.hpp.

Referenced by mmx::tensor::add(), and mmx::tensor::waddm().

00165   {
00166     for ( unsigned * ea = aadd; ea != aadd + nadd; a[*ea++] += *b++ ) ;
00167   };

void mmx::vct::ipsub ( A *  a,
unsigned *  aadd,
unsigned  nadd,
const B *  b 
) [inline]

Definition at line 170 of file tensor_vctops.hpp.

Referenced by mmx::tensor::sub(), and mmx::tensor::wsubm().

00171   {
00172     for ( unsigned * ea = aadd; ea != aadd + nadd; a[*ea++] -= *b++ ) ;
00173   };

real_t mmx::vct::max ( real_t const *  src,
int  sz,
int  st = 1 
) [inline]

Definition at line 488 of file tensor_vctops.hpp.

00489     {
00490       real_t r = src[0];
00491       for ( int p = st; p != sz*st; p += st ) if ( r < src[p] ) r = src[p];    
00492       return r;
00493     };

void mmx::vct::max ( A &  mx,
B const *  v,
unsigned  n,
int  s = 1 
) [inline]

Definition at line 200 of file tensor_vctops.hpp.

References accmax().

00201   {
00202     mx = v[0];
00203     accmax(mx,v,n,s) ;
00204   };

real_t mmx::vct::min ( real_t const *  src,
int  sz,
int  st = 1 
) [inline]

Definition at line 480 of file tensor_vctops.hpp.

00481     {
00482       real_t r = src[0];
00483       for ( int p = st; p != sz*st; p += st ) if ( r > src[p] ) r = src[p];    
00484       return r;
00485     };

void mmx::vct::min ( A &  mn,
B const *  v,
unsigned  n,
int  s = 1 
) [inline]

Definition at line 185 of file tensor_vctops.hpp.

References accmin().

Referenced by conv().

00186   {
00187     mn = v[0];
00188     accmin(mn,v+s,n-1,s) ;
00189   };

void mmx::vct::minmax ( C &  m,
C &  M,
const C *  a,
unsigned  n,
unsigned  s = 1 
) [inline]
Parameters:
m minimum value.
M maximum value.
a base address of coefficients.
n number of coefficients.
s increment used to access a.

Definition at line 317 of file tensor_vctops.hpp.

References C.

00318   {
00319     for ( const C * e = a + n*s-s, m = M = *e; a < e; a += 2*s )
00320       {
00321         if ( *a > *(a+s) )
00322           {
00323             if ( *a > M ) M = *a; 
00324             if ( *(a+s) < m ) m = *(a+s) ;
00325           }
00326         else 
00327           {
00328             if ( *a > M ) M = *a;
00329             if ( *(a+s) < m ) m = *(a+s) ;
00330           };
00331       };
00332   };

void mmx::vct::mmerge ( C *  r,
int  str,
const C *  a,
unsigned  na,
int  sta,
const C *  b,
unsigned  nb,
int  stb 
) [inline]

Definition at line 355 of file tensor_vctops.hpp.

References C.

00358   {
00359     C * er(r);
00360     const C * ea(a), * eb(b);
00361     
00362     a += na*sta;
00363     b += nb*stb;
00364     
00365     for (;;)
00366       {
00367         for (;ea != a && *ea < *eb; *er = *ea, er += str, ea += sta ) ;
00368         
00369         if (  ea == a ) 
00370           { 
00371             for ( ; eb != b; *er = *eb, er += str, eb += stb ) ;
00372             break;
00373           };
00374         
00375         if ( *ea == *eb ) 
00376           { 
00377             *er = *ea;
00378             er += str;
00379             ea += sta;
00380             eb += stb;
00381           };
00382         
00383         for (;eb != b && *eb < *ea; *er = *eb, er += str, eb += stb ) ;
00384 
00385         if (  eb == b ) 
00386           { 
00387             for ( ; ea != a; *er = *ea, er += str, ea += sta ) ;
00388             break;
00389           };
00390         
00391         if ( *eb == *ea ) 
00392           { 
00393             *er = *eb;
00394             er += str;
00395             eb += stb;
00396             ea += sta;
00397           };
00398       };
00399     return (er - r)/str;
00400   };

unsigned mmx::vct::mmerge ( C *  r,
const C *  a,
const C *  b,
unsigned  na,
unsigned  nb 
) [inline]

Definition at line 335 of file tensor_vctops.hpp.

References C, and copy().

00337   {
00338     C * er(r);
00339     const C * ea(a), * eb(b);
00340     a += na;
00341     b += nb;
00342     for (;;)
00343       {
00344         while( ea < a && *ea < *eb ) *er++ = *ea++;
00345         if (  ea == a ) { std::copy(eb,b,er) ; break; };
00346         if ( *ea == *eb ) { *er++ = *ea++; eb++;};
00347         while( eb < b && *eb < *ea ) *er++ = *eb++;
00348         if (  eb == b ) { std::copy(ea,a,er); break; };
00349         if ( *eb == *ea ) { *er++ = *eb++; ea++;};
00350       };
00351     return er-r;
00352   };

void mmx::vct::padd ( A *  a,
const B *  b,
const C *  c,
unsigned  sz,
int  sta = 1,
int  stb = 1,
int  stc = 1 
) [inline]

Definition at line 19 of file tensor_vctops.hpp.

00021   { 
00022     for ( A * ea = a; ea != a+sz*sta; *ea = *b+*c, ea += sta, b += stb, c += stc ) ;
00023   };

void mmx::vct::padd ( A *  a,
const B *  b,
unsigned  sz,
int  sta = 1,
int  stb = 1 
) [inline]

Definition at line 13 of file tensor_vctops.hpp.

00014   { 
00015     for ( A * ea = a; ea != a+sz*sta; *ea += *b , ea += sta, b += stb ) {}
00016   };

void mmx::vct::pdiv ( A *  a,
const B *  b,
const C *  c,
unsigned  sz,
int  sta = 1,
int  stb = 1,
int  stc = 1 
) [inline]

Definition at line 56 of file tensor_vctops.hpp.

00057   { 
00058     for ( A * ea = a; ea != a+sz*sta; *ea = *b/(*c), ea += sta, b += stb, c += stc ) ; 
00059   };

void mmx::vct::pdiv ( A *  a,
const B *  b,
unsigned  sz,
int  sta = 1,
int  stb = 1 
) [inline]

Definition at line 50 of file tensor_vctops.hpp.

Referenced by mmx::tensor::uscale().

00051   { 
00052     for ( A * ea = a; ea != a+sz*sta; *ea /= *b, ea += sta, b += stb ) ; 
00053   };

void mmx::vct::pmul ( A *  a,
const B *  b,
const C *  c,
unsigned  sz,
int  sta = 1,
int  stb = 1,
int  stc = 1 
) [inline]

Definition at line 44 of file tensor_vctops.hpp.

00045   { 
00046     for ( A * ea = a; ea != a+sz*sta; *ea = *b**c, ea += sta, b += stb, c += stc ) ; 
00047   };

void mmx::vct::pmul ( A *  a,
const B *  b,
int  sz,
int  sta = 1,
int  stb = 1 
) [inline]

Definition at line 38 of file tensor_vctops.hpp.

Referenced by mmx::tensor::binoms(), and mmx::tensor::scale().

00039   { 
00040     for ( A * ea = a; ea != a+sz*sta; *ea *= *b, ea += sta, b += stb ) ; 
00041   };

void mmx::vct::print ( const A *  p,
unsigned  n,
int  st = 1,
std::ostream &  o = std::cout 
) [inline]

Definition at line 206 of file tensor_vctops.hpp.

00208   {
00209     const A * i;
00210     o << "[ ";
00211     for ( i = p; i != p + (n-1)*st; i += st )
00212       o << *i << ", ";
00213     o << *i << " ]";
00214   };

void mmx::vct::psub ( A *  a,
const B *  b,
const C *  c,
unsigned  sz,
int  sta = 1,
int  stb = 1,
int  stc = 1 
) [inline]

Definition at line 32 of file tensor_vctops.hpp.

00033   { 
00034     for ( A * ea = a; ea != a+sz*sta; *ea = *b-*c, ea += sta, b += stb, c += stc ) ; 
00035   };

void mmx::vct::psub ( A *  a,
const B *  b,
unsigned  sz,
int  sta = 1,
int  stb = 1 
) [inline]

Definition at line 26 of file tensor_vctops.hpp.

00027   { 
00028     for ( A * ea = a; ea != a+sz*sta; *ea -= *b, ea += sta, b += stb ) ; 
00029   };

void mmx::vct::scadd ( A *  a,
const B *  b,
const C &  c,
unsigned  n,
int  sa = 1,
int  sb = 1 
) [inline]

Definition at line 68 of file tensor_vctops.hpp.

00069   {
00070     for ( A * ea = a; ea != a + n*sa; *ea = *b + c, ea += sa, b += sb ) ;
00071   };

void mmx::vct::scadd ( A *  a,
const B &  b,
unsigned  n,
int  s = 1 
) [inline]

Definition at line 62 of file tensor_vctops.hpp.

00063   { 
00064     for ( A * ea = a; ea != a + n*s; *a += b, ea += s ) ;
00065   };

static void mmx::vct::scale ( C *  p,
const C &  s,
unsigned  n,
int  is = 1 
) [inline, static]

Definition at line 413 of file tensor_vctops.hpp.

References C.

00414   {
00415     C pw = s;
00416     for (C * cp = p + is; cp != p + n * is; *cp *= pw, pw *= s, cp += is) ;
00417   };

void mmx::vct::scdiv ( A *  a,
const C &  c,
const B *  b,
unsigned  n,
int  sa = 1,
int  sb = 1 
) [inline]

Definition at line 134 of file tensor_vctops.hpp.

00135   {
00136     for ( A * ea = a; ea != a + n*sa; *ea = c/(*b), ea += sa, b += sb ) ;
00137   }

void mmx::vct::scdiv ( A *  a,
const B *  b,
const C &  c,
unsigned  n,
int  sa = 1,
int  sb = 1 
) [inline]

Definition at line 128 of file tensor_vctops.hpp.

00129   {
00130     for ( A * ea = a; ea != a + n*sa; *ea = *b/c, ea += sa, b += sb ) ;
00131   }

void mmx::vct::scdiv ( const B &  b,
A *  a,
unsigned  n,
int  s = 1 
) [inline]

Definition at line 122 of file tensor_vctops.hpp.

00123   {
00124     for ( A * ea = a; ea != a+n*s; *ea = b/(*ea), ea += s ) ;
00125   };

void mmx::vct::scdiv ( A *  a,
const B &  b,
unsigned  n,
int  s = 1 
) [inline]

Definition at line 116 of file tensor_vctops.hpp.

00117   { 
00118     for ( A * ea = a; ea != a+n*s; *ea /= b, ea += s ) ;
00119   }

void mmx::vct::scmul ( A *  a,
const A *  _a,
const B *  b,
const C &  c 
) [inline]

Definition at line 110 of file tensor_vctops.hpp.

00111   {
00112     for ( A * ea = a; ea != _a; *ea++ = *b++*c ) ;
00113   }

void mmx::vct::scmul ( A *  a,
const B *  b,
const C &  c,
unsigned  n,
int  sa = 1,
int  sb = 1 
) [inline]

Definition at line 104 of file tensor_vctops.hpp.

00105   {
00106     for ( A * ea = a; ea != a + n*sa; *ea = *b*c, ea += sa, b += sb ) ;
00107   }

void mmx::vct::scmul ( A *  a,
const B &  b,
unsigned  n,
int  s = 1 
) [inline]

Definition at line 98 of file tensor_vctops.hpp.

Referenced by mmx::tensor::mdiff().

00099   { 
00100     for ( A * ea = a; ea != a+n*s; *ea *= b, ea += s ) ;
00101   }

void mmx::vct::scsub ( A *  a,
const B &  b,
const C *  c,
unsigned  n,
int  sa = 1,
int  sb = 1 
) [inline]

Definition at line 92 of file tensor_vctops.hpp.

00093   {
00094     for ( A * ea = a; ea != a+n*sa; *ea = c-*b, ea += sa, b += sb ) ;
00095   };

void mmx::vct::scsub ( A *  a,
const B *  b,
const C &  c,
unsigned  n,
int  sa = 1,
int  sb = 1 
) [inline]

Definition at line 86 of file tensor_vctops.hpp.

00087   { 
00088     for ( A * ea = a; ea != a+n*sa; *ea = *b-c, ea += sa, b += sb ) ;
00089   }

void mmx::vct::scsub ( const B &  b,
A *  a,
unsigned  n,
int  s = 1 
) [inline]

Definition at line 80 of file tensor_vctops.hpp.

00081   {
00082     for ( A * ea = a; ea != a+n*s;  *ea = b-*ea, ea += s ) ;
00083   }

void mmx::vct::scsub ( A *  a,
const B &  b,
unsigned  n,
int  s = 1 
) [inline]

Definition at line 74 of file tensor_vctops.hpp.

00075   { 
00076     for ( A * ea = a; ea != a + n*s; *ea -= b, ea += s ) ;
00077   };

static void mmx::vct::shift ( C *  p,
const C &  c,
unsigned  n,
int  is = 1 
) [inline, static]

Definition at line 405 of file tensor_vctops.hpp.

00406   {
00407     int j, k, s;
00408     for (s = n, j = 0; j <= s - 2; j++)
00409       for (k = s - 2; k >= j; p[k * is] += c * p[k * is + is], k--) ;
00410   };


Generated on 6 Dec 2012 for realroot by  doxygen 1.6.1