File indexing completed on 2026-04-09 07:49:15
0001 #include "s_pmt.h"
0002 #include "NPFold.h"
0003
0004 struct s_pmt_test
0005 {
0006 static int desc();
0007
0008
0009 static int lpmtidx();
0010 static NP* lpmtidx_array();
0011
0012 static int oldcontiguousidx();
0013 static NP* oldcontiguousidx_array();
0014
0015 static int contiguousidx();
0016 static NP* contiguousidx_array();
0017
0018
0019
0020 static NPFold* makefold_();
0021 static int makefold();
0022
0023 static int main();
0024 };
0025
0026 int s_pmt_test::desc()
0027 {
0028 std::cout << s_pmt::desc() ;
0029 return 0;
0030 }
0031
0032 int s_pmt_test::lpmtidx()
0033 {
0034 for(int i=0 ; i < s_pmt::NUM_LPMTIDX ; i++)
0035 {
0036 int lpmtidx = i ;
0037 int lpmtid = s_pmt::pmtid_from_lpmtidx(lpmtidx);
0038 int lpmtidx_1 = s_pmt::lpmtidx_from_pmtid(lpmtid);
0039 assert( lpmtidx_1 == lpmtidx );
0040 }
0041 return 0;
0042 }
0043
0044 NP* s_pmt_test::lpmtidx_array()
0045 {
0046 int ni = s_pmt::NUM_LPMTIDX ;
0047 int nj = 3 ;
0048 NP* a = NP::Make<int>( ni, nj );
0049 int* aa = a->values<int>();
0050 for(int i=0 ; i < ni ; i++)
0051 {
0052 int lpmtidx = i ;
0053 int lpmtid = s_pmt::pmtid_from_lpmtidx(lpmtidx);
0054 int contiguousidx = s_pmt::contiguousidx_from_pmtid(lpmtid);
0055
0056 aa[i*nj+0] = lpmtidx ;
0057 aa[i*nj+1] = lpmtid ;
0058 aa[i*nj+2] = contiguousidx ;
0059 }
0060 a->labels = new std::vector<std::string> { "lpmtidx", "lpmtid", "contiguousidx" };
0061 return a ;
0062 }
0063
0064
0065 int s_pmt_test::oldcontiguousidx()
0066 {
0067 for(int i=0 ; i < s_pmt::NUM_OLDCONTIGUOUSIDX ; i++)
0068 {
0069 int oldcontiguousidx = i ;
0070 int pmtid = s_pmt::pmtid_from_oldcontiguousidx(oldcontiguousidx);
0071 int oldcontiguousidx_1 = s_pmt::oldcontiguousidx_from_pmtid(pmtid);
0072 assert( oldcontiguousidx_1 == oldcontiguousidx );
0073 }
0074 return 0;
0075 }
0076
0077 NP* s_pmt_test::oldcontiguousidx_array()
0078 {
0079 int ni = s_pmt::NUM_OLDCONTIGUOUSIDX ;
0080 int nj = 3 ;
0081 NP* a = NP::Make<int>( ni, nj );
0082 int* aa = a->values<int>();
0083 for(int i=0 ; i < ni ; i++)
0084 {
0085 int oldcontiguousidx = i ;
0086 int pmtid = s_pmt::pmtid_from_oldcontiguousidx(oldcontiguousidx);
0087 int lpmtidx = s_pmt::lpmtidx_from_pmtid(pmtid);
0088
0089 aa[i*nj+0] = oldcontiguousidx ;
0090 aa[i*nj+1] = pmtid ;
0091 aa[i*nj+2] = lpmtidx ;
0092 }
0093
0094 a->labels = new std::vector<std::string> { "oldcontiguousidx", "pmtid", "lpmtidx" };
0095
0096 return a ;
0097 }
0098
0099
0100
0101
0102
0103
0104
0105 int s_pmt_test::contiguousidx()
0106 {
0107 for(int i=0 ; i < s_pmt::NUM_CONTIGUOUSIDX ; i++)
0108 {
0109 int contiguousidx = i ;
0110 int pmtid = s_pmt::pmtid_from_contiguousidx(contiguousidx);
0111 int contiguousidx_1 = s_pmt::contiguousidx_from_pmtid(pmtid);
0112 assert( contiguousidx_1 == contiguousidx );
0113 }
0114 return 0;
0115 }
0116
0117 NP* s_pmt_test::contiguousidx_array()
0118 {
0119 int ni = s_pmt::NUM_CONTIGUOUSIDX ;
0120 int nj = 3 ;
0121 NP* a = NP::Make<int>( ni, nj );
0122 int* aa = a->values<int>();
0123 for(int i=0 ; i < ni ; i++)
0124 {
0125 int contiguousidx = i ;
0126 int pmtid = s_pmt::pmtid_from_contiguousidx(contiguousidx);
0127 int lpmtidx = s_pmt::lpmtidx_from_pmtid(pmtid);
0128
0129 aa[i*nj+0] = contiguousidx ;
0130 aa[i*nj+1] = pmtid ;
0131 aa[i*nj+2] = lpmtidx ;
0132 }
0133
0134 a->labels = new std::vector<std::string> { "contiguousidx", "pmtid", "lpmtidx" };
0135
0136 return a ;
0137 }
0138
0139
0140
0141
0142
0143
0144 NPFold* s_pmt_test::makefold_()
0145 {
0146 NPFold* f = new NPFold ;
0147 f->add( "lpmtidx" , lpmtidx_array() );
0148 f->add( "oldcontiguousidx" , oldcontiguousidx_array() );
0149 f->add( "contiguousidx" , contiguousidx_array() );
0150 return f ;
0151 }
0152
0153 int s_pmt_test::makefold()
0154 {
0155 NPFold* f = makefold_();
0156 f->save("$FOLD");
0157 return 0;
0158 }
0159
0160
0161 int s_pmt_test::main()
0162 {
0163 int rc = 0 ;
0164 rc += desc();
0165 rc += lpmtidx();
0166 rc += oldcontiguousidx();
0167 rc += contiguousidx();
0168 rc += makefold();
0169 return rc ;
0170 }
0171
0172
0173 int main()
0174 {
0175 return s_pmt_test::main() ;
0176 }