2 **********************************************************************
3 $SNARK_Header: S N A R K 1 4 - A PICTURE RECONSTRUCTION PROGRAM $
4 $HeadURL: svn://dig.cs.gc.cuny.edu/snark/trunk/src/snark/effpick.cpp $
5 $LastChangedRevision: 79 $
6 $Date: 2014-07-01 15:33:39 -0400 (Tue, 01 Jul 2014) $
8 **********************************************************************
19 void factorization(INTEGER num, INTEGER** decomp, INTEGER *num_dig)
21 // factorizes num and put the factors into vector decomp of size num_dig
23 INTEGER m2s, nipf, mnipf, k;
29 { //bug 144 earlier version gets *num_dig=0 when num == 1
31 *decomp = new INTEGER[1];
39 mnipf = (INTEGER) ceil(log((REAL) num) / log(2.0));
41 ipf = new INTEGER[mnipf];
42 primfc(num, &m2s, &nipf, ipf, mnipf);
44 *num_dig = m2s + nipf;
45 *decomp = new INTEGER[*num_dig];
47 for (k = 0; k < m2s; k++)
52 for (k = 0; k < nipf; k++)
54 (*decomp)[k + m2s] = ipf[k];
57 delete[] ipf; //wei 3/2005
62 void tau_map(INTEGER num_dig, INTEGER* decomp, INTEGER* old_num,
65 // see the definition of the tau mapping in "Herman and Meyer. Algebraic reconstruction techniques can be made computationally efficient. IEEE Trans. on Medical Imaging 12: 600--609. 1993"
66 static INTEGER cont, ind;
70 for (cont = 0; cont < num_dig; cont++)
78 for (cont = 0; cont < num_dig; cont++)
80 if (old_num[cont] != decomp[cont] - 1)
87 for (cont = 0; cont < num_dig; cont++)
95 new_num[cont] = old_num[cont] + 1;
99 new_num[cont] = old_num[cont];
103 for (cont = 0; cont < num_dig; cont++)
104 old_num[cont] = new_num[cont];
107 void get_base(INTEGER* decomp, INTEGER num_dig, INTEGER** base)
109 // given the factorization vector decomp (of size num_dig) in increasing order, the routine returns another vector whose components are the accumulative product of decomp in the reversed order
114 *base = new INTEGER[num_dig];
116 (*base)[num_dig - 1] = 1;
118 for (cont = 0; cont < num_dig - 1; cont++)
120 aux = aux * decomp[num_dig - cont - 1];
121 (*base)[num_dig - cont - 2] = aux;
128 void nu_map(INTEGER num_dig, INTEGER* base, INTEGER* num, INTEGER* result)
130 // given the the vector num whose components are the digits of a number written in base "base", this routines returns that number as "result"
135 for (cont = 0; cont < num_dig; cont++)
137 *result = *result + base[cont] * num[cont];
142 void pi_map(INTEGER num_dig, INTEGER* decomp, INTEGER* base, INTEGER** old_num,
143 INTEGER** new_num, INTEGER* res)
145 // given the factorizaton vector decomp and the vector base, this routines is the composition of nu_map and tau_map
147 tau_map(num_dig, decomp, (*old_num), (*new_num));
148 nu_map(num_dig, base, (*new_num), res);