35#ifndef STK_PRODUCTRAW_H 
   36#define STK_PRODUCTRAW_H 
   89template<
typename Lhs, 
typename Rhs, 
typename Result>
 
   92  typedef typename Result::Type 
Type;
 
   99      res.elt(
i, 
j) += lhs.elt(
i, k) * rhs.elt(k, 
j);
 
 
  106      res.elt(
i) += lhs.elt(
i, k) * rhs.elt(k);
 
 
  113      res.elt(
j) += lhs.elt(k) * rhs.elt(k, 
j);
 
 
  119    switch (lhs.sizeRows())
 
  122      case 1: 
mul1XX(lhs, rhs, 
res); 
return true;
 
  123      case 2: 
mul2XX(lhs, rhs, 
res); 
return true;
 
  124      case 3: 
mul3XX(lhs, rhs, 
res); 
return true;
 
  125      case 4: 
mul4XX(lhs, rhs, 
res); 
return true;
 
  126      case 5: 
mul5XX(lhs, rhs, 
res); 
return true;
 
  127      case 6: 
mul6XX(lhs, rhs, 
res); 
return true;
 
  128      case 7: 
mul7XX(lhs, rhs, 
res); 
return true;
 
  131    switch (lhs.sizeCols())
 
  133      case 0: 
return true; 
break;
 
  134      case 1: 
mulX1X(lhs, rhs, 
res); 
return true;
 
  135      case 2: 
mulX2X(lhs, rhs, 
res); 
return true;
 
  136      case 3: 
mulX3X(lhs, rhs, 
res); 
return true;
 
  137      case 4: 
mulX4X(lhs, rhs, 
res); 
return true;
 
  138      case 5: 
mulX5X(lhs, rhs, 
res); 
return true;
 
  139      case 6: 
mulX6X(lhs, rhs, 
res); 
return true;
 
  140      case 7: 
mulX7X(lhs, rhs, 
res); 
return true;
 
  143    switch (rhs.sizeCols())
 
  146      case 1: 
mulXX1(lhs, rhs, 
res); 
return true;
 
  147      case 2: 
mulXX2(lhs, rhs, 
res); 
return true;
 
  148      case 3: 
mulXX3(lhs, rhs, 
res); 
return true;
 
  149      case 4: 
mulXX4(lhs, rhs, 
res); 
return true;
 
  150      case 5: 
mulXX5(lhs, rhs, 
res); 
return true;
 
  151      case 6: 
mulXX6(lhs, rhs, 
res); 
return true;
 
  152      case 7: 
mulXX7(lhs, rhs, 
res); 
return true;
 
 
  160    int const lhsRow = lhs.beginRows();
 
  161    for (
int j=rhs.beginCols(); 
j< rhs.endCols(); ++
j)
 
  162      for (
int k=rhs.beginRows(); k< rhs.endRows(); ++k)
 
 
  168    int const i = lhs.beginRows();
 
  169    for (
int j=rhs.beginCols(); 
j< rhs.endCols(); ++
j)
 
  170      for (
int k=rhs.beginRows(); k< rhs.endRows(); ++k)
 
  172         res.elt(
i  , 
j) += lhs.elt(
i  , k) * rhs.elt(k, 
j);
 
  173         res.elt(
i+1, 
j) += lhs.elt(
i+1, k) * rhs.elt(k, 
j);
 
 
  179    int const i = lhs.beginRows();
 
  180    for (
int j=rhs.beginCols(); 
j< rhs.endCols(); ++
j)
 
  181      for (
int k=rhs.beginRows(); k< rhs.endRows(); ++k)
 
  183        res.elt(
i  , 
j) += lhs.elt(
i  , k) * rhs.elt(k, 
j);
 
  184        res.elt(
i+1, 
j) += lhs.elt(
i+1, k) * rhs.elt(k, 
j);
 
  185        res.elt(
i+2, 
j) += lhs.elt(
i+2, k) * rhs.elt(k, 
j);
 
 
  191    int const i = lhs.beginRows();
 
  192    for (
int j=rhs.beginCols(); 
j< rhs.endCols(); ++
j)
 
  193      for (
int k=rhs.beginRows(); k< rhs.endRows(); ++k)
 
  195        res.elt(
i  , 
j) += lhs.elt(
i  , k) * rhs.elt(k, 
j);
 
  196        res.elt(
i+1, 
j) += lhs.elt(
i+1, k) * rhs.elt(k, 
j);
 
  197        res.elt(
i+2, 
j) += lhs.elt(
i+2, k) * rhs.elt(k, 
j);
 
  198        res.elt(
i+3, 
j) += lhs.elt(
i+3, k) * rhs.elt(k, 
j);
 
 
  204    int const i = lhs.beginRows();
 
  205    for (
int j=rhs.beginCols(); 
j< rhs.endCols(); ++
j)
 
  206      for (
int k=rhs.beginRows(); k< rhs.endRows(); ++k)
 
  208        res.elt(
i  , 
j) += lhs.elt(
i  , k) * rhs.elt(k, 
j);
 
  209        res.elt(
i+1, 
j) += lhs.elt(
i+1, k) * rhs.elt(k, 
j);
 
  210        res.elt(
i+2, 
j) += lhs.elt(
i+2, k) * rhs.elt(k, 
j);
 
  211        res.elt(
i+3, 
j) += lhs.elt(
i+3, k) * rhs.elt(k, 
j);
 
  212        res.elt(
i+4, 
j) += lhs.elt(
i+4, k) * rhs.elt(k, 
j);
 
 
  218    int const i = lhs.beginRows();
 
  219    for (
int j=rhs.beginCols(); 
j< rhs.endCols(); ++
j)
 
  220      for (
int k=rhs.beginRows(); k< rhs.endRows(); ++k)
 
  222        res.elt(
i  , 
j) += lhs.elt(
i  , k) * rhs.elt(k, 
j);
 
  223        res.elt(
i+1, 
j) += lhs.elt(
i+1, k) * rhs.elt(k, 
j);
 
  224        res.elt(
i+2, 
j) += lhs.elt(
i+2, k) * rhs.elt(k, 
j);
 
  225        res.elt(
i+3, 
j) += lhs.elt(
i+3, k) * rhs.elt(k, 
j);
 
  226        res.elt(
i+4, 
j) += lhs.elt(
i+4, k) * rhs.elt(k, 
j);
 
  227        res.elt(
i+5, 
j) += lhs.elt(
i+5, k) * rhs.elt(k, 
j);
 
 
  233    int const i = lhs.beginRows();
 
  234    for (
int j=rhs.beginCols(); 
j< rhs.endCols(); ++
j)
 
  235      for (
int k=rhs.beginRows(); k< rhs.endRows(); ++k)
 
  237        res.elt(
i  , 
j) += lhs.elt(
i  , k) * rhs.elt(k, 
j);
 
  238        res.elt(
i+1, 
j) += lhs.elt(
i+1, k) * rhs.elt(k, 
j);
 
  239        res.elt(
i+2, 
j) += lhs.elt(
i+2, k) * rhs.elt(k, 
j);
 
  240        res.elt(
i+3, 
j) += lhs.elt(
i+3, k) * rhs.elt(k, 
j);
 
  241        res.elt(
i+4, 
j) += lhs.elt(
i+4, k) * rhs.elt(k, 
j);
 
  242        res.elt(
i+5, 
j) += lhs.elt(
i+5, k) * rhs.elt(k, 
j);
 
  243        res.elt(
i+6, 
j) += lhs.elt(
i+6, k) * rhs.elt(k, 
j);
 
 
  249    int const k = lhs.beginCols();
 
  250    for (
int i=lhs.beginRows(); 
i< lhs.endRows(); ++
i)
 
  251      for (
int j=rhs.beginCols(); 
j< rhs.endCols(); ++
j)
 
  252        res.elt(
i, 
j) += lhs.elt(
i, k) * rhs.elt(k, 
j);
 
 
  257    int const k = lhs.beginCols();
 
  258    for (
int i=lhs.beginRows(); 
i< lhs.endRows(); ++
i)
 
  259      for (
int j=rhs.beginCols(); 
j< rhs.endCols(); ++
j)
 
  261        res.elt(
i, 
j) += lhs.elt(
i, k)   * rhs.elt(k, 
j);
 
  262        res.elt(
i, 
j) += lhs.elt(
i, k+1) * rhs.elt(k+1, 
j);
 
 
  268    int const k = lhs.beginCols();
 
  269    for (
int i=lhs.beginRows(); 
i< lhs.endRows(); ++
i)
 
  270      for (
int j=rhs.beginCols(); 
j< rhs.endCols(); ++
j)
 
  272        res.elt(
i, 
j) += lhs.elt(
i, k)   * rhs.elt(k, 
j);
 
  273        res.elt(
i, 
j) += lhs.elt(
i, k+1) * rhs.elt(k+1, 
j);
 
  274        res.elt(
i, 
j) += lhs.elt(
i, k+2) * rhs.elt(k+2, 
j);
 
 
  280    int const k = lhs.beginCols();
 
  281    for (
int i=lhs.beginRows(); 
i< lhs.endRows(); ++
i)
 
  282      for (
int j=rhs.beginCols(); 
j< rhs.endCols(); ++
j)
 
  284        res.elt(
i, 
j) += lhs.elt(
i, k)   * rhs.elt(k, 
j);
 
  285        res.elt(
i, 
j) += lhs.elt(
i, k+1) * rhs.elt(k+1, 
j);
 
  286        res.elt(
i, 
j) += lhs.elt(
i, k+2) * rhs.elt(k+2, 
j);
 
  287        res.elt(
i, 
j) += lhs.elt(
i, k+3) * rhs.elt(k+3, 
j);
 
 
  293    int const k = lhs.beginCols();
 
  294    for (
int i=lhs.beginRows(); 
i< lhs.endRows(); ++
i)
 
  295      for (
int j=rhs.beginCols(); 
j< rhs.endCols(); ++
j)
 
  297        res.elt(
i, 
j) += lhs.elt(
i, k)   * rhs.elt(k, 
j);
 
  298        res.elt(
i, 
j) += lhs.elt(
i, k+1) * rhs.elt(k+1, 
j);
 
  299        res.elt(
i, 
j) += lhs.elt(
i, k+2) * rhs.elt(k+2, 
j);
 
  300        res.elt(
i, 
j) += lhs.elt(
i, k+3) * rhs.elt(k+3, 
j);
 
  301        res.elt(
i, 
j) += lhs.elt(
i, k+4) * rhs.elt(k+4, 
j);
 
 
  307    int const k = lhs.beginCols();
 
  308    for (
int i=lhs.beginRows(); 
i< lhs.endRows(); ++
i)
 
  309      for (
int j=rhs.beginCols(); 
j< rhs.endCols(); ++
j)
 
  311        res.elt(
i, 
j) += lhs.elt(
i, k)   * rhs.elt(k, 
j);
 
  312        res.elt(
i, 
j) += lhs.elt(
i, k+1) * rhs.elt(k+1, 
j);
 
  313        res.elt(
i, 
j) += lhs.elt(
i, k+2) * rhs.elt(k+2, 
j);
 
  314        res.elt(
i, 
j) += lhs.elt(
i, k+3) * rhs.elt(k+3, 
j);
 
  315        res.elt(
i, 
j) += lhs.elt(
i, k+4) * rhs.elt(k+4, 
j);
 
  316        res.elt(
i, 
j) += lhs.elt(
i, k+5) * rhs.elt(k+5, 
j);
 
 
  322    int const k = lhs.beginCols();
 
  323    for (
int i=lhs.beginRows(); 
i< lhs.endRows(); ++
i)
 
  324      for (
int j=rhs.beginCols(); 
j< rhs.endCols(); ++
j)
 
  326        res.elt(
i, 
j) += lhs.elt(
i, k)   * rhs.elt(k, 
j);
 
  327        res.elt(
i, 
j) += lhs.elt(
i, k+1) * rhs.elt(k+1, 
j);
 
  328        res.elt(
i, 
j) += lhs.elt(
i, k+2) * rhs.elt(k+2, 
j);
 
  329        res.elt(
i, 
j) += lhs.elt(
i, k+3) * rhs.elt(k+3, 
j);
 
  330        res.elt(
i, 
j) += lhs.elt(
i, k+4) * rhs.elt(k+4, 
j);
 
  331        res.elt(
i, 
j) += lhs.elt(
i, k+5) * rhs.elt(k+5, 
j);
 
  332        res.elt(
i, 
j) += lhs.elt(
i, k+6) * rhs.elt(k+6, 
j);
 
 
  338    int const j = rhs.beginCols();
 
  339    for (
int i=lhs.beginRows(); 
i< lhs.endRows(); ++
i)
 
  340      for (
int k=lhs.beginCols(); k< lhs.endCols(); ++k)
 
  341        res.elt(
i, 
j) += lhs.elt(
i, k) * rhs.elt(k, 
j);
 
 
  346    int const j = rhs.beginCols();
 
  347    for (
int i=lhs.beginRows(); 
i< lhs.endRows(); ++
i)
 
  348      for (
int k=lhs.beginCols(); k< lhs.endCols(); ++k)
 
  350        res.elt(
i, 
j  ) += lhs.elt(
i, k) * rhs.elt(k, 
j  );
 
  351        res.elt(
i, 
j+1) += lhs.elt(
i, k) * rhs.elt(k, 
j+1);
 
 
  357    int const j = rhs.beginCols();
 
  358    for (
int i=lhs.beginRows(); 
i< lhs.endRows(); ++
i)
 
  359      for (
int k=lhs.beginCols(); k< lhs.endCols(); ++k)
 
  361        res.elt(
i, 
j  ) += lhs.elt(
i, k) * rhs.elt(k, 
j  );
 
  362        res.elt(
i, 
j+1) += lhs.elt(
i, k) * rhs.elt(k, 
j+1);
 
  363        res.elt(
i, 
j+2) += lhs.elt(
i, k) * rhs.elt(k, 
j+2);
 
 
  369    int const j = rhs.beginCols();
 
  370    for (
int i=lhs.beginRows(); 
i< lhs.endRows(); ++
i)
 
  371      for (
int k=lhs.beginCols(); k< lhs.endCols(); ++k)
 
  373        res.elt(
i, 
j  ) += lhs.elt(
i, k) * rhs.elt(k, 
j  );
 
  374        res.elt(
i, 
j+1) += lhs.elt(
i, k) * rhs.elt(k, 
j+1);
 
  375        res.elt(
i, 
j+2) += lhs.elt(
i, k) * rhs.elt(k, 
j+2);
 
  376        res.elt(
i, 
j+3) += lhs.elt(
i, k) * rhs.elt(k, 
j+3);
 
 
  382    int const j = rhs.beginCols();
 
  383    for (
int i=lhs.beginRows(); 
i< lhs.endRows(); ++
i)
 
  384      for (
int k=lhs.beginCols(); k< lhs.endCols(); ++k)
 
  386        res.elt(
i, 
j  ) += lhs.elt(
i, k) * rhs.elt(k, 
j  );
 
  387        res.elt(
i, 
j+1) += lhs.elt(
i, k) * rhs.elt(k, 
j+1);
 
  388        res.elt(
i, 
j+2) += lhs.elt(
i, k) * rhs.elt(k, 
j+2);
 
  389        res.elt(
i, 
j+3) += lhs.elt(
i, k) * rhs.elt(k, 
j+3);
 
  390        res.elt(
i, 
j+4) += lhs.elt(
i, k) * rhs.elt(k, 
j+4);
 
 
  396    int const j = rhs.beginCols();
 
  397    for (
int i=lhs.beginRows(); 
i< lhs.endRows(); ++
i)
 
  398      for (
int k=lhs.beginCols(); k< lhs.endCols(); ++k)
 
  400        res.elt(
i, 
j  ) += lhs.elt(
i, k) * rhs.elt(k, 
j  );
 
  401        res.elt(
i, 
j+1) += lhs.elt(
i, k) * rhs.elt(k, 
j+1);
 
  402        res.elt(
i, 
j+2) += lhs.elt(
i, k) * rhs.elt(k, 
j+2);
 
  403        res.elt(
i, 
j+3) += lhs.elt(
i, k) * rhs.elt(k, 
j+3);
 
  404        res.elt(
i, 
j+4) += lhs.elt(
i, k) * rhs.elt(k, 
j+4);
 
  405        res.elt(
i, 
j+5) += lhs.elt(
i, k) * rhs.elt(k, 
j+5);
 
 
  411    int const j = rhs.beginCols();
 
  412    for (
int i=lhs.beginRows(); 
i< lhs.endRows(); ++
i)
 
  413      for (
int k=lhs.beginCols(); k< lhs.endCols(); ++k)
 
  415        res.elt(
i, 
j  ) += lhs.elt(
i, k) * rhs.elt(k, 
j  );
 
  416        res.elt(
i, 
j+1) += lhs.elt(
i, k) * rhs.elt(k, 
j+1);
 
  417        res.elt(
i, 
j+2) += lhs.elt(
i, k) * rhs.elt(k, 
j+2);
 
  418        res.elt(
i, 
j+3) += lhs.elt(
i, k) * rhs.elt(k, 
j+3);
 
  419        res.elt(
i, 
j+4) += lhs.elt(
i, k) * rhs.elt(k, 
j+4);
 
  420        res.elt(
i, 
j+5) += lhs.elt(
i, k) * rhs.elt(k, 
j+5);
 
  421        res.elt(
i, 
j+6) += lhs.elt(
i, k) * rhs.elt(k, 
j+6);
 
 
  427    for (
int i=lhs.beginRows(); 
i< lhs.endRows(); ++
i)
 
  428      for (
int j=rhs.beginCols(); 
j< rhs.endCols(); ++
j)
 
  429        res.elt(
i,
j) += lhs.elt(
i, k) * rhs.elt(k, 
j);
 
 
  434    for (
int i=lhs.beginRows(); 
i< lhs.endRows(); ++
i)
 
  435      for (
int j=rhs.beginCols(); 
j< rhs.endCols(); ++
j)
 
  436        res.elt(
i,
j) += lhs.elt(
i, k  ) * rhs.elt(k,   
j)
 
  437                      + lhs.elt(
i, k+1) * rhs.elt(k+1, 
j);
 
 
  442    for (
int i=lhs.beginRows(); 
i< lhs.endRows(); ++
i)
 
  443      for (
int j=rhs.beginCols(); 
j< rhs.endCols(); ++
j)
 
  444        res.elt(
i,
j) += lhs.elt(
i, k  ) * rhs.elt(k, 
j)
 
  445                      + lhs.elt(
i, k+1) * rhs.elt(k+1, 
j)
 
  446                      + lhs.elt(
i, k+2) * rhs.elt(k+2, 
j);
 
 
 
  453template<
typename Array, 
typename Type = 
typename Array::Type>
 
The MultidimRegression class allows to regress a multidimensional output variable among a multivariat...
Index sub-vector region: Specialization when the size is unknown.
Range inf(TRange< SizeI_ > const &I, TRange< SizeJ_ > const &J)
compute inf(I,J).
The namespace STK is the main domain space of the Statistical ToolKit project.
TRange< panelSize_ > panelRange
TRange< blockSize_ > blockRange
This structure encapsulate the data allocated for a block.
Type const & operator[](int i) const
Type block[blockSize_ *blockSize_]
This structure regroup the methods to used for copying part of an array in a Block or a Panel.
static void arrayToPanel(Array const &m, Panel< Type > &panel, int iRow, int jCol)
copy a part of an array in a Panel
static void arrayToBlockByCol(Array const &m, Block< Type > &block, int iRow, int jCol)
default dimensions
static void arrayToPanel(Array const &rhs, Panel< Type > &panel, int iRow, int jCol, int pSize)
copy a part of an array in a panel with Panel columns size given
static void arrayToBlock(Array const &m, Block< Type > &block, int iRow, int jCol)
copy a part of an Array in a Block
static void arrayToPanelByCol(Array const &m, Panel< Type > &panel, int iRow, int kPos, int pSize)
with panel size dimension given
static void arrayToBlockByCol(Array const &m, Block< Type > &block, int iRow, int jCol, int bSize)
with block size given
static void arrayToPanelByCol(Array const &m, Panel< Type > &panel, int iRow, int kPos)
default dimensions
static void arrayToBlock(Array const &m, Block< Type > &block, int iRow, int jCol, int bSize)
copy a part of an Array in a Block with block columns size given
This structure regroup the methods to used after block multiplication in order to perform the product...
static void mult2Outer(Lhs const &lhs, Rhs const &rhs, Result &res, int k)
multiplication with two outer rows/columns
static void dot(Lhs const &lhs, ITContainer< Rhs, Arrays::vector_ > const &rhs, Result &res, int i)
dot product.
static void mult1Outer(Lhs const &lhs, Rhs const &rhs, Result &res, int k)
multiplication with one outer rows/columns
static void dot(Lhs const &lhs, Rhs const &rhs, Result &res, int i, int j)
dot product.
static void mulXX5(Lhs const &lhs, Rhs const &rhs, Result &res)
multiplication with Rhs having 5 columns
static void mult3Outer(Lhs const &lhs, Rhs const &rhs, Result &res, int k)
multiplication with three outer rows/columns
static void mulX4X(Lhs const &lhs, Rhs const &rhs, Result &res)
multiplication with Lhs having 4 columns and Rhs having 4 rows
static void mulXX7(Lhs const &lhs, Rhs const &rhs, Result &res)
multiplication with Rhs having 7 columns
static void mulXX3(Lhs const &lhs, Rhs const &rhs, Result &res)
multiplication with Rhs having 3 columns
static void mulXX2(Lhs const &lhs, Rhs const &rhs, Result &res)
multiplication with Rhs having 2 columns
static void mulX6X(Lhs const &lhs, Rhs const &rhs, Result &res)
multiplication with Lhs having 6 columns and Rhs having 6 rows
static void mul2XX(Lhs const &lhs, Rhs const &rhs, Result &res)
multiplication with Lhs having 2 rows
static void mul1XX(Lhs const &lhs, Rhs const &rhs, Result &res)
multiplication with Lhs having 1 row
static void mulXX4(Lhs const &lhs, Rhs const &rhs, Result &res)
multiplication with Rhs having 4 columns
static void mulX7X(Lhs const &lhs, Rhs const &rhs, Result &res)
multiplication with Lhs having 7 columns and Rhs having 7 rows
static void mul5XX(Lhs const &lhs, Rhs const &rhs, Result &res)
multiplication with Lhs having 5 rows
static void mul4XX(Lhs const &lhs, Rhs const &rhs, Result &res)
multiplication with Lhs having 4 rows
static void mul6XX(Lhs const &lhs, Rhs const &rhs, Result &res)
multiplication with Lhs having 6 rows
static void dot(ITContainer< Lhs, Arrays::point_ > const &lhs, Rhs const &rhs, Result &res, int j)
dot product.
static void mul7XX(Lhs const &lhs, Rhs const &rhs, Result &res)
multiplication with Lhs having 7 rows
static void mulXX6(Lhs const &lhs, Rhs const &rhs, Result &res)
multiplication with Rhs having 6 columns
static void mulX2X(Lhs const &lhs, Rhs const &rhs, Result &res)
multiplication with Lhs having 2 columns and Rhs having 2 rows
static bool multDispatcher(Lhs const &lhs, Rhs const &rhs, Result &res)
static void mulX1X(Lhs const &lhs, Rhs const &rhs, Result &res)
multiplication with Lhs having 1 column and Rhs having 1 row
static void mul3XX(Lhs const &lhs, Rhs const &rhs, Result &res)
multiplication with Lhs having 3 rows
static void mulXX1(Lhs const &lhs, Rhs const &rhs, Result &res)
multiplication with Rhs having 1 column
static void mulX5X(Lhs const &lhs, Rhs const &rhs, Result &res)
multiplication with Lhs having 5 columns and Rhs having 5 rows
static void mulX3X(Lhs const &lhs, Rhs const &rhs, Result &res)
multiplication with Lhs having 3 columns and Rhs having 3 rows
This structure encapsulate the data allocated for a panel.
Type panel[blockSize_ *panelSize_]
Type const & operator[](int i) const
This structure encapsulate the data allocated for a block.
Type const & operator[](int i) const