1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
|
/*1:*/
#line 6 "./pyramid_prod2.cweb"
#include "pyramid_prod2.h"
#include "rfs_tensor.h"
/*2:*/
#line 21 "./pyramid_prod2.cweb"
IrregTensorHeader::IrregTensorHeader(const StackProduct<FGSTensor> &sp,
const IntSequence&c)
:nv(sp.getAllSize()),
unit_flag(sp.dimen()),
cols(new Vector*[sp.dimen()]),
end_seq(sp.dimen())
{
sp.createPackedColumns(c,cols,unit_flag);
for(int i= 0;i<sp.dimen();i++){
end_seq[i]= cols[i]->length();
if(unit_flag[i]!=-1)
end_seq[i]= unit_flag[i]+1;
}
}
/*:2*/
#line 10 "./pyramid_prod2.cweb"
;
/*3:*/
#line 42 "./pyramid_prod2.cweb"
void IrregTensorHeader::increment(IntSequence&v)const
{
TL_RAISE_IF(v.size()!=dimen(),
"Wrong size of coordinates in IrregTensorHeader::increment");
if(v.size()==0)
return;
int i= v.size()-1;
/*4:*/
#line 63 "./pyramid_prod2.cweb"
v[i]++;
if(unit_flag[i]!=-1&&v[i]==cols[i]->length()-1)
v[i]= unit_flag[i];
/*:4*/
#line 51 "./pyramid_prod2.cweb"
;
while(i> 0&&v[i]==end_seq[i]){
v[i]= 0;
i--;
/*4:*/
#line 63 "./pyramid_prod2.cweb"
v[i]++;
if(unit_flag[i]!=-1&&v[i]==cols[i]->length()-1)
v[i]= unit_flag[i];
/*:4*/
#line 55 "./pyramid_prod2.cweb"
;
}
}
/*:3*/
#line 11 "./pyramid_prod2.cweb"
;
/*5:*/
#line 70 "./pyramid_prod2.cweb"
IrregTensorHeader::~IrregTensorHeader()
{
for(int i= 0;i<dimen();i++)
delete cols[i];
delete[]cols;
}
/*:5*/
#line 12 "./pyramid_prod2.cweb"
;
/*6:*/
#line 79 "./pyramid_prod2.cweb"
int IrregTensorHeader::calcMaxOffset()const
{
int res= 1;
for(int i= 0;i<dimen();i++)
res*= cols[i]->length();
return res;
}
/*:6*/
#line 13 "./pyramid_prod2.cweb"
;
/*7:*/
#line 92 "./pyramid_prod2.cweb"
IrregTensor::IrregTensor(const IrregTensorHeader&h)
:Tensor(along_row,IntSequence(h.dimen(),0),h.end_seq,
h.calcMaxOffset(),1,h.dimen()),
header(h)
{
if(header.dimen()==1){
getData()= *(header.cols[0]);
return;
}
Vector*last= new Vector(*(header.cols[header.dimen()-1]));
for(int i= header.dimen()-2;i> 0;i--){
Vector*newlast= new Vector(last->length()*header.cols[i]->length());
KronProd::kronMult(ConstVector(*(header.cols[i])),
ConstVector(*last),*newlast);
delete last;
last= newlast;
}
KronProd::kronMult(ConstVector(*(header.cols[0])),
ConstVector(*last),getData());
delete last;
}
/*:7*/
#line 14 "./pyramid_prod2.cweb"
;
/*8:*/
#line 117 "./pyramid_prod2.cweb"
void IrregTensor::addTo(FRSingleTensor&out)const
{
for(index it= begin();it!=end();++it){
IntSequence tmp(it.getCoor());
tmp.sort();
Tensor::index ind(&out,tmp);
out.get(*ind,0)+= get(*it,0);
}
}
/*:8*/
#line 15 "./pyramid_prod2.cweb"
;
/*:1*/
|