7 #include "StMultiArray.h"
9 StMultiArrayBase::StMultiArrayBase(
int n1,
int n2)
15 StMultiArrayBase::StMultiArrayBase(
int n1,
int n2,
int n3)
21 StMultiArrayBase::StMultiArrayBase(
int n1,
int n2,
int n3,
int n4)
23 int des[]={n1,n2,n3,n4};
27 StMultiArrayBase::StMultiArrayBase(
int n1,
int n2,
int n3,
int n4,
int n5)
29 int des[]={n1,n2,n3,n4,n5};
33 StMultiArrayBase::StMultiArrayBase(
int n1,
int n2,
int n3,
int n4,
int n5,
int n6)
35 int des[]={n1,n2,n3,n4,n5,n6};
39 StMultiArrayBase::StMultiArrayBase(
int n1,
int n2,
int n3,
int n4,
int n5,
int n6,
int n7)
41 int des[]={n1,n2,n3,n4,n5,n6,n7};
45 StMultiArrayBase::StMultiArrayBase(
int n1,
int n2,
int n3,
int n4,
int n5,
int n6,
int n7,
int n8)
47 int des[]={n1,n2,n3,n4,n5,n6,n7,n8};
51 void StMultiArrayBase::Init(
int *sz,
int n)
53 memset(
this,0,
sizeof(*
this));
56 for (
int i=n-1;i>=0;i--) {mDes[i]=mDes[i+1]*sz[i];}
59 void StMultiArrayBase::AddIdx(
int i)
61 mSft +=mDes[++mTally]*i;
62 assert(mTally<=mNDes+1);
65 int StMultiArrayBase::GetIdx()
67 assert(mTally==mNDes);
68 int i=mSft; mSft=0; mTally=0;
72 int StMultiArrayBase::GetKdx()
74 assert(mTally==mNDes-1);
75 int i=mSft; mSft=0; mTally=0;
79 void StMultiArrayBase::Clear()
84 void StMultiArrayBase::Test()
87 for (
int i1=0;i1<2;i1++) {
88 for (
int i2=0;i2<3;i2++) {
89 for (
int i3=0;i3<4;i3++) {A[i1][i2][i3] = 100*i1+10*i2+i3;}}};
93 for (
int i1=0;i1<2;i1++) {
94 for (
int i2=0;i2<3;i2++) {
95 for (
int i3=0;i3<4;i3++) {
96 int v = MA[i1][i2][i3];
98 printf(
"%d = %d = %d\n",100*i1+10*i2+i3,v,vp[i3]);