realroot_doc 0.1.1
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.

    { 
      real_t const * src = _src_;
      while ( src != _src_ + sz*stsrc ) { *dst += *src*sc; src += stsrc; dst += stdst; };
    };
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 
)

Definition at line 212 of file loops_vctops.hpp.

References assert.

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

    {
      assert((dst!=a)&&(dst!=b));
      int p,ia,ib,q;
      for ( p = 0; p != (sza+szb-1)*stout; dst[p] = (U)0, p += stout ) ;
      for ( p = ia =0; ia != sza*sta; ia += sta, p += stout ) 
        for ( ib = 0, q = p; ib != szb*stb; dst[q] += a[ia]*b[ib], ib += stb, q += stout ) ;
    };
real_t mmx::vctops::delta_max ( real_t *  a,
real_t *  b,
unsigned  sz,
int  st = 1 
) [inline]

Definition at line 173 of file loops_vctops.hpp.

    {
      int p = st;
      real_t tmp = a[0]-b[0];
      for ( unsigned i = 1; i < sz; i++ , p += st )
        if ( a[p]-b[p] > tmp ) tmp = a[p]-b[p];
      return tmp;
    };
int mmx::vctops::delta_max_index ( real_t *  a,
real_t *  b,
unsigned  sz,
int  st = 1 
) [inline]

Definition at line 183 of file loops_vctops.hpp.

    {
      int mx = 0;
      int p = st;
      real_t tmp = a[0]-b[0];
      for ( unsigned i = 1; i < sz; i++ , p += st )
        if ( a[p]-b[p] > tmp ) { mx = i; tmp = a[p]-b[p]; };
      return mx;
    };
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 164 of file loops_vctops.hpp.

    { 
      real_t s; 
      int pa,pb;
      for ( s = pb = pa = 0; pa != sz*sta; pa += sta, pb += stb ) s += (a[pa]-b[pb])*(a[pa]-b[pb]); 
      return s; 
    };
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.

    { 
      real_t acc = 0.0; 
      for ( int p = 0; p != sz*sta; p += sta, b += stb ) acc += a[p]*(*b); 
      return acc; 
    };
real_t mmx::vctops::max ( real_t const *  src,
int  sz,
int  st = 1 
)
real_t mmx::vctops::mean ( real_t const *const  data,
int  sz,
int  st 
)

Definition at line 123 of file loops_vctops.hpp.

    { 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 
)

Definition at line 96 of file loops_vctops.hpp.

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

    {
      real_t r = src[0];
      for ( int p = st; p != sz*st; p += st ) if ( r > src[p] ) r = src[p];    
      return r;
    };
void mmx::vctops::minmax ( real0 &  min,
real0 &  max,
real_t *  src,
int  sz,
int  st = 1 
)

Definition at line 87 of file loops_vctops.hpp.

References minmaxu().

Referenced by scale().

    {
      int i,p;
      min = src[(sz-1)*st];
      max = src[(sz-1)*st];
      minmaxu(min,max,src,sz,st);
    };
void mmx::vctops::minmaxu ( real0 &  min,
real0 &  max,
real_t *  src,
int  sz,
int  st = 1 
)

Definition at line 68 of file loops_vctops.hpp.

Referenced by minmax().

    {
      int i,p;
      for ( p = 0, i = 0; i < sz/2; i ++, p += 2*st )
        {
          if ( src[p] < src[p+st] ) 
            {
              if ( src[p]    < min ) min = src[p];
              if ( src[p+st] > max ) max = src[p+st];
            }
          else 
            {
              if ( src[p]    > max ) max = src[p];
              if ( src[p+st] < min ) min = src[p+st];
            };
        };
    };
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().

    { 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.

    { 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().

    { 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 
)

Definition at line 127 of file loops_vctops.hpp.

    {
      int p = 0;
      out << "[ ";
      for ( unsigned i = 0; i < sz-1; i++, p += st )
        {
          out << data[p];
          out << ", ";
        };
      out << data[p] << " ]";
      return out;
    };
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().

    { 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 208 of file loops_vctops.hpp.

References minmax(), and scmul().

    { 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().

    { 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().

    { 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.

    { 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().

    { 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 
)

Definition at line 222 of file loops_vctops.hpp.

    {
      int p,q,ia,ib;
      for ( p = 0; p != (2*sza-1); dst[p] = 0, p += stout ) ;
      for ( p = ia = 0; ia != sza*sta; dst[2*p] += a[ia]*a[ia], ia += sta, p += stout )
        for ( ib = 0, q = p; ib != ia; dst[q] += 2*a[ia]*a[ib], ib += sta, q += stout ) ;
    };
unsigned mmx::vctops::set_conversion ( real_t *  src,
unsigned  sz,
const real_t &  epsilon = (real_t)0 
) [inline]

Definition at line 198 of file loops_vctops.hpp.

Referenced by op_mul().

    {
      std::sort(src,src+sz);
      unsigned c = 0;
      for ( unsigned i = 1; i < sz; i++ )
        if ( src[i]-src[c] > epsilon ) src[++c] = src[i];
      return c+1;
    };
bool mmx::vctops::sgnchg ( real_t const *const  b,
unsigned  sz,
int  st = 1 
) [inline]

Definition at line 151 of file loops_vctops.hpp.

References mmx::abs().

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

    {
      int p = st;
      if ( std::abs(b[0]) < numerics::epsilon<real_t>::result || 
           std::abs(b[(sz-1)*st]) < numerics::epsilon<real_t>::result ) return true;
      bool pprv = b[0]>0;//numerics::epsilon<real_t>::result;
      //      bool pcurr;
      for ( unsigned i = 1; i < sz; i++, p+= st )  
        if ( (b[p]>0) != pprv )  return true;
      return false;
    };
unsigned mmx::vctops::sgncnt ( real_t const *  b,
unsigned  sz,
int  st = 1 
) [inline]

Definition at line 141 of file loops_vctops.hpp.

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

    {
      real_t const * last = b + (sz-1)*st;
      unsigned c;
      for ( c = 0; b != last; b += st )
        c += *b > 0 != *(b+st) > 0;
      return c;
    };
real_t mmx::vctops::sum ( real_t const *const  src,
unsigned  sz,
int  st = 1 
) [inline]

Definition at line 194 of file loops_vctops.hpp.

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

    {  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 
)

Definition at line 113 of file loops_vctops.hpp.

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