mmx::vctops Namespace Reference

Functions


Function Documentation

void mmx::vctops::accscmul ( real_t *  dst,
const real_t &  sc,
real_t const *  _src_,
int  sz,
int  stdst = 1,
int  stsrc = 1 
) [inline]

Definition at line 27 of file loops_vctops.hpp.

00028     { 
00029       real_t const * src = _src_;
00030       while ( src != _src_ + sz*stsrc ) { *dst += *src*sc; src += stsrc; dst += stdst; };
00031     };

void mmx::vctops::convolution ( U *  dst,
Y const *  a,
Z const *  b,
unsigned  sza,
unsigned  szb,
int  sta = 1,
int  stb = 1,
int  stout = 1 
) [inline]

Definition at line 211 of file loops_vctops.hpp.

References assert.

Referenced by bzenv< X >::scaled_elevate().

00212     {
00213       assert((dst!=a)&&(dst!=b));
00214       int p,ia,ib,q;
00215       for ( p = 0; p != (sza+szb-1)*stout; dst[p] = (U)0, p += stout ) ;
00216       for ( p = ia =0; ia != sza*sta; ia += sta, p += stout ) 
00217         for ( ib = 0, q = p; ib != szb*stb; dst[q] += a[ia]*b[ib], ib += stb, q += stout ) ;
00218     };

real_t mmx::vctops::delta_max ( real_t *  a,
real_t *  b,
unsigned  sz,
int  st = 1 
) [inline]

Definition at line 172 of file loops_vctops.hpp.

00173     {
00174       int p = st;
00175       real_t tmp = a[0]-b[0];
00176       for ( unsigned i = 1; i < sz; i++ , p += st )
00177         if ( a[p]-b[p] > tmp ) tmp = a[p]-b[p];
00178       return tmp;
00179     };

int mmx::vctops::delta_max_index ( real_t *  a,
real_t *  b,
unsigned  sz,
int  st = 1 
) [inline]

Definition at line 182 of file loops_vctops.hpp.

00183     {
00184       int mx = 0;
00185       int p = st;
00186       real_t tmp = a[0]-b[0];
00187       for ( unsigned i = 1; i < sz; i++ , p += st )
00188         if ( a[p]-b[p] > tmp ) { mx = i; tmp = a[p]-b[p]; };
00189       return mx;
00190     };

real_t mmx::vctops::distance2 ( real_t const *const   a,
real_t const *const   b,
unsigned  sz,
int  sta,
int  stb 
) [inline]

Definition at line 163 of file loops_vctops.hpp.

00164     { 
00165       real_t s; 
00166       int pa,pb;
00167       for ( s = pb = pa = 0; pa != sz*sta; pa += sta, pb += stb ) s += (a[pa]-b[pb])*(a[pa]-b[pb]); 
00168       return s; 
00169     };

real_t mmx::vctops::dotprod ( const real_t *  a,
const real_t *  b,
int  sz,
int  sta = 1,
int  stb = 1 
) [inline]

Definition at line 44 of file loops_vctops.hpp.

00045     { 
00046       real_t acc = 0.0; 
00047       for ( int p = 0; p != sz*sta; p += sta, b += stb ) acc += a[p]*(*b); 
00048       return acc; 
00049     };

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

Definition at line 122 of file loops_vctops.hpp.

00123     { real_t mv   = 0.0; for ( int p = 0; p != sz*st; mv += data[p], p += st ) ; return mv/sz; };

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

Definition at line 95 of file loops_vctops.hpp.

Referenced by abs_max_coeff(), mmx::hull(), mmx::intersect(), and min_coeff().

00096     {
00097       real_t r = src[0];
00098       for ( int p = st; p != sz*st; p += st ) if ( r > src[p] ) r = src[p];    
00099       return r;
00100     };

void mmx::vctops::minmax ( real0 &  min,
real0 &  max,
real_t *  src,
int  sz,
int  st = 1 
) [inline]

Definition at line 87 of file loops_vctops.hpp.

References minmaxu().

Referenced by scale().

00088     {
00089       min = src[(sz-1)*st];
00090       max = src[(sz-1)*st];
00091       minmaxu(min,max,src,sz,st);
00092     };

void mmx::vctops::minmaxu ( real0 &  min,
real0 &  max,
real_t *  src,
int  sz,
int  st = 1 
) [inline]

Definition at line 68 of file loops_vctops.hpp.

Referenced by minmax().

00069     {
00070       int i,p;
00071       for ( p = 0, i = 0; i < sz/2; i ++, p += 2*st )
00072         {
00073           if ( src[p] < src[p+st] ) 
00074             {
00075               if ( src[p]    < min ) min = src[p];
00076               if ( src[p+st] > max ) max = src[p+st];
00077             }
00078           else 
00079             {
00080               if ( src[p]    > max ) max = src[p];
00081               if ( src[p+st] < min ) min = src[p+st];
00082             };
00083         };
00084     };

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

Definition at line 52 of file loops_vctops.hpp.

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

00053     { for ( int p = 0; p != sz*sta; p += sta, b += stb ) a[p] += *b; };

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

Definition at line 64 of file loops_vctops.hpp.

00065     { int p; for ( p  = 0; p != sz*sta; a[p] /= *b, p += sta, b += stb ) ; };

void mmx::vctops::pmul ( real_t *  a,
const real_t *  b,
unsigned  sz,
int  sta = 1,
int  stb = 1 
) [inline]

Definition at line 60 of file loops_vctops.hpp.

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

00061     { for ( int p = 0; p != sz*sta; p += sta, b += stb ) a[p] *= *b; };

std::ostream& mmx::vctops::print ( real_t const *const   data,
unsigned  sz,
int  st = 1,
std::ostream &  out = std::cout 
) [inline]

Definition at line 126 of file loops_vctops.hpp.

00127     {
00128       int p = 0;
00129       out << "[ ";
00130       for ( unsigned i = 0; i < sz-1; i++, p += st )
00131         {
00132           out << data[p];
00133           out << ", ";
00134         };
00135       out << data[p] << " ]";
00136       return out;
00137     };

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

Definition at line 56 of file loops_vctops.hpp.

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

00057     { for ( int p = 0; p != sz*sta; p += sta, b += stb ) a[p] -= *b; };

void mmx::vctops::scale ( real_t *  src,
unsigned  sz,
const real_t &  sc = (real_t)(1.0),
int  st = 1 
) [inline]

Definition at line 207 of file loops_vctops.hpp.

References minmax(), and scmul().

00208     { real_t mn,mx; minmax(mn,mx,src,sz,st); scmul(sc/(mx-mn),src,sz,st); };

void mmx::vctops::scdiv ( const real_t &  sc,
real_t *  data,
int  sz,
int  st = 1 
) [inline]

Definition at line 39 of file loops_vctops.hpp.

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

00040     { for ( int p = 0; p != sz*st; p += st ) data[p] /= sc; };

void mmx::vctops::scmul ( const real_t &  sc,
real_t *  data,
int  sz,
int  st = 1 
) [inline]

Definition at line 35 of file loops_vctops.hpp.

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

00036     { for ( int p = 0; p != sz*st; p += st ) data[p] *= sc; };

void mmx::vctops::scsub ( const real_t &  sc,
real_t *  data,
const real_t *  src,
int  sz,
int  sta = 1,
int  stb = 1 
) [inline]

Definition at line 23 of file loops_vctops.hpp.

00024     { int pd,p; for ( pd = p = 0; p !=sz*sta; p += sta, pd += stb ) data[pd] = src[p]-sc; };

void mmx::vctops::scsub ( const real_t &  sc,
real_t *  data,
int  sz,
int  st = 1 
) [inline]

Definition at line 19 of file loops_vctops.hpp.

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

00020     { for ( int p = 0; p !=sz*st; p += st ) data[p] -= sc;  };

void mmx::vctops::self_convolution ( U *  dst,
Y const *  a,
unsigned  sza,
int  sta = 1,
int  stout = 1 
) [inline]

Definition at line 221 of file loops_vctops.hpp.

00222     {
00223       int p,q,ia,ib;
00224       for ( p = 0; p != (2*sza-1); dst[p] = 0, p += stout ) ;
00225       for ( p = ia = 0; ia != sza*sta; dst[2*p] += a[ia]*a[ia], ia += sta, p += stout )
00226         for ( ib = 0, q = p; ib != ia; dst[q] += 2*a[ia]*a[ib], ib += sta, q += stout ) ;
00227     };

unsigned mmx::vctops::set_conversion ( real_t *  src,
unsigned  sz,
const real_t &  epsilon = (real_t)0 
) [inline]

Definition at line 197 of file loops_vctops.hpp.

Referenced by op_mul().

00198     {
00199       std::sort(src,src+sz);
00200       unsigned c = 0;
00201       for ( unsigned i = 1; i < sz; i++ )
00202         if ( src[i]-src[c] > epsilon ) src[++c] = src[i];
00203       return c+1;
00204     };

bool mmx::vctops::sgnchg ( real_t const *const   b,
unsigned  sz,
int  st = 1 
) [inline]

Definition at line 150 of file loops_vctops.hpp.

References mmx::abs().

Referenced by parallel< system >::process().

00151     {
00152       int p = st;
00153       if ( std::abs(b[0]) < numerics::epsilon<real_t>::result || 
00154            std::abs(b[(sz-1)*st]) < numerics::epsilon<real_t>::result ) return true;
00155       bool pprv = b[0]>0;//numerics::epsilon<real_t>::result;
00156       //      bool pcurr;
00157       for ( unsigned i = 1; i < sz; i++, p+= st )  
00158         if ( (b[p]>0) != pprv )  return true;
00159       return false;
00160     };

unsigned mmx::vctops::sgncnt ( real_t const *  b,
unsigned  sz,
int  st = 1 
) [inline]

Definition at line 140 of file loops_vctops.hpp.

Referenced by descartes_solver< real_t, local_method >::solve().

00141     {
00142       real_t const * last = b + (sz-1)*st;
00143       unsigned c;
00144       for ( c = 0; b != last; b += st )
00145         c += *b > 0 != *(b+st) > 0;
00146       return c;
00147     };

real_t mmx::vctops::sum ( real_t const *const   src,
unsigned  sz,
int  st = 1 
) [inline]

Definition at line 193 of file loops_vctops.hpp.

Referenced by mmx::linear::doolittle(), mmx::linear::Lsolve(), NISP< C >::upper_bound(), and mmx::linear::Usolve().

00194     {  real_t acc = (real_t)0.0; for ( int i = 0; i != sz*st; acc += src[i], i += st ) ; return acc;}; 

void mmx::vctops::urand ( T *  data,
unsigned  sz,
const T &  a,
const T &  b,
int  st = 1 
) [inline]

Definition at line 112 of file loops_vctops.hpp.

00113     {
00114       for ( int p = 0; p != sz*st; p += st )
00115         {
00116           double t = ((double)rand()/(double)RAND_MAX);
00117           data[p] = T(((1.0-t)*a + t*b));
00118         };
00119     };


Generated on 6 Dec 2012 for realroot by  doxygen 1.6.1