Skip to content

Commit ae9083e

Browse files
committed
tidying of preprocessor macros
1 parent 96543f7 commit ae9083e

File tree

13 files changed

+59
-79
lines changed

13 files changed

+59
-79
lines changed

libsrc/eclib/flinterface.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
#include <flint/nmod_mat.h>
5050
#include <flint/profiler.h>
5151

52-
#if (__FLINT_VERSION>2)&&(SCALAR_OPTION==1) // using 32-bit int scalars
52+
#if (__FLINT_VERSION>2)&&defined(scalar_is_int) // using 32-bit int scalars
5353

5454
typedef unsigned int hlimb_t;
5555

@@ -108,7 +108,7 @@ hmod_mat_rref(hmod_mat_t mat);
108108
#define mod_mat_rref hmod_mat_rref
109109
#define mod_mat_mul hmod_mat_mul
110110

111-
#else // __FLINT_VERSION<3 or SCALAR_OPTION=2 -- using 64-bit int scalars
111+
#else // __FLINT_VERSION<3 or scalar_is_long -- using 64-bit int scalars
112112

113113
#undef uscalar
114114
#undef mod_mat

libsrc/eclib/homspace.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,12 @@ class homspace :public symbdata {
7272
long op_prime(int i); // the i'th operator prime for Tp or Wq
7373
mat opmat(int i, int dual, int verb=0);
7474
vec opmat_col(int i, int j, int verb=0);
75-
mat opmat_cols(int i, const vec& jlist, int verb=0);
75+
mat opmat_cols(int i, const vec_i& jlist, int verb=0);
7676
mat opmat_restricted(int i,const subspace& s, int dual, int verb=0);
7777
// versions returning an smat:
7878
smat s_opmat(int i,int dual,int verb=0);
7979
svec s_opmat_col(int i, int j, int verb=0);
80-
smat s_opmat_cols(int i, const vec& jlist, int verb=0);
80+
smat s_opmat_cols(int i, const vec_i& jlist, int verb=0);
8181
smat s_opmat_restricted(int i,const ssubspace& s, int dual,int verb=0);
8282

8383
// Extend a dual vector of length rk to one of length nsymb:
@@ -138,24 +138,24 @@ class homspace :public symbdata {
138138

139139
mat calcop(string opname, long p, const matop& mlist, int dual, int display=0) const;
140140
vec calcop_col(string opname, long p, int j, const matop& mlist, int display=0) const;
141-
mat calcop_cols(string opname, long p, const vec& jlist, const matop& mlist, int display=0) const;
141+
mat calcop_cols(string opname, long p, const vec_i& jlist, const matop& mlist, int display=0) const;
142142
mat calcop_restricted(string opname, long p, const matop& mlist, const subspace& s, int dual, int display=0) const;
143143

144144
smat s_calcop(string opname, long p, const matop& mlist, int dual, int display=0) const;
145145
svec s_calcop_col(string opname, long p, int j, const matop& mlist, int display=0) const;
146-
smat s_calcop_cols(string opname, long p, const vec& jlist, const matop& mlist, int display=0) const;
146+
smat s_calcop_cols(string opname, long p, const vec_i& jlist, const matop& mlist, int display=0) const;
147147
smat s_calcop_restricted(string opname, long p, const matop& mlist, const ssubspace& s, int dual, int display=0) const;
148148

149149
public:
150150

151151
mat heckeop(long p, int dual, int display=0) const;
152152
vec heckeop_col(long p, int j, int display=0) const;
153-
mat heckeop_cols(long p, const vec& jlist, int display=0) const;
153+
mat heckeop_cols(long p, const vec_i& jlist, int display=0) const;
154154
mat heckeop_restricted(long p, const subspace& s, int dual, int display=0) const;
155155

156156
smat s_heckeop(long p, int dual, int display=0) const;
157157
svec s_heckeop_col(long p, int j, int display=0) const;
158-
smat s_heckeop_cols(long p, const vec& jlist, int display=0) const;
158+
smat s_heckeop_cols(long p, const vec_i& jlist, int display=0) const;
159159
smat s_heckeop_restricted(long p, const ssubspace& s, int dual, int display=0) const;
160160

161161
mat newheckeop(long p, int dual, int display=0) const;
@@ -164,11 +164,11 @@ class homspace :public symbdata {
164164
mat fricke(int dual, int display=0) const;
165165
mat conj(int dual, int display=0) const;
166166
vec conj_col(int j, int display=0) const;
167-
mat conj_cols(const vec& jlist, int display=0) const;
167+
mat conj_cols(const vec_i& jlist, int display=0) const;
168168
mat conj_restricted(const subspace& s, int dual,int display=0) const;
169169
smat s_conj(int dual, int display=0) const;
170170
svec s_conj_col(int j, int display=0) const;
171-
smat s_conj_cols(const vec& jlist, int display=0) const;
171+
smat s_conj_cols(const vec_i& jlist, int display=0) const;
172172
smat s_conj_restricted(const ssubspace& s, int dual, int display=0) const;
173173
vec maninvector(long p) const;
174174
vec projmaninvector(long p) const;

libsrc/eclib/method.h

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -41,37 +41,28 @@
4141
#define MODULAR // Causes linear algebra to be done modulo global MODULUS
4242
#endif
4343

44-
#if (METHOD==3)||(METHOD==4)
45-
#define MULTI
46-
#define SCALAR_OPTION 3
47-
#endif
48-
49-
//The next two cause scalar, vector, matrix to be defined properly:
5044
#if (METHOD==0)||(METHOD==2)
5145
#define SCALAR_OPTION 1
5246
#endif
5347
#if (METHOD==5)||(METHOD==6)
5448
#define SCALAR_OPTION 2
5549
#endif
50+
#if (METHOD==3)||(METHOD==4)
51+
#define SCALAR_OPTION 3
52+
#endif
5653

57-
#include <eclib/subspace.h>
54+
// types.h presets scalar, vec, mat, subspace, ssubspace, svec, smat, smat_elim
55+
// to be int/long/bigint and *_i/*_l/*_m according to SCALAR_OPTION
5856
#include "types.h"
5957

60-
#ifdef MULTI
61-
typedef bigint SCALAR;
62-
typedef vec_m VEC;
63-
typedef mat_m MAT;
64-
typedef subspace_m SUBSP;
65-
#include <eclib/subspace.h>
58+
#if (SCALAR_OPTION==3)
6659
#define MODULUS to_ZZ("6074000003")
6760
#else
6861
#define MODULUS DEFAULT_MODULUS // (set in xmod.h) used for modular linear algebra
69-
typedef scalar SCALAR;
70-
typedef vec VEC;
71-
typedef mat MAT;
72-
typedef subspace SUBSP;
7362
#endif
7463

64+
#include <eclib/subspace.h>
65+
7566
#ifdef MODULAR
7667
#define EIGENSPACE(a,b) peigenspace(a,b,MODULUS)
7768
#define SUBEIGENSPACE(a,b,c) psubeigenspace(a,b,c,MODULUS)

libsrc/eclib/newforms.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ class newforms :public level, splitter_base {
171171
smat s_opmat_restricted(int i, const ssubspace& s, int d, int v=0)
172172
{return h1->s_opmat_restricted(i,s,d,v);}
173173
long matdim(void) {return h1->dimension;}
174-
long matden(void) {return h1->denom1;}
174+
scalar matden(void) {return h1->denom1;}
175175
vector<long> eigrange(int i) {return h1->eigrange(i);}
176176
long dimoldpart(const vector<long> l);
177177
protected:

libsrc/eclib/splitbase.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class splitter_base {
6060
virtual smat s_opmat_cols(int i, const vec& jlist, int verb=0) = 0;
6161
virtual smat s_opmat_restricted(int,const ssubspace& s, int, int=0) = 0;
6262
virtual long matdim(void) = 0;
63-
virtual long matden(void) = 0;
63+
virtual scalar matden(void) = 0;
6464
virtual vector<long> eigrange(int) = 0;
6565
virtual long dimoldpart(const vector<long>) = 0;
6666
virtual void use(const vec&, const vec&, const vector<long>) = 0;

libsrc/eclib/vec.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class vec {
6161
void set(long i, const scalar& x); // sets v[i]=x
6262
void add(long i, const scalar& x); // v[i]+=x
6363
void add_modp(long i, const scalar& x, const scalar& p); // v[i]+=x mod p
64-
void red_modp(const scalar& p); // reduce mod p in place
64+
void reduce_mod_p(const scalar& p); // reduce mod p in place
6565
scalar sub(long i) const; // same as v[i] (no ref)
6666
const vector<scalar> get_entries()const {return entries;}
6767
static vec iota(long n); // (1,2,...,n)
@@ -126,9 +126,9 @@ inline vec operator+(const vec& v1, const vec& v2)
126126
inline vec addmodp(const vec& v1, const vec& v2, const scalar& pr)
127127
{ vec w(v1); w.addmodp(v2,pr); return w;}
128128

129-
inline vec reduce_modp(const vec& v, const scalar& p)
129+
inline vec reduce_mod_p(const vec& v, const scalar& p)
130130
{
131-
vec w(v); w.red_modp(p); return w;
131+
vec w(v); w.reduce_mod_p(p); return w;
132132
}
133133

134134
inline vec operator-(const vec& v1, const vec& v2)

libsrc/eclib/xsplit.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class form_finder {
7373
int plusflag, dual, bigmats, verbose, targetdim;
7474
int gnfcount; // Global newform counter
7575
long maxdepth, mindepth, dimen;
76-
SCALAR denom1;
76+
scalar denom1;
7777
vector< vector<long> > gaplist; // Vector to hold all (sub)eiglists
7878
vector<vec> gbplus, gbminus; // Vector to hold all bplus/bminus
7979

libsrc/homspace.cc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ vec homspace::calcop_col(string opname, long p, int j, const matop& mlist,
679679
return colj;
680680
}
681681

682-
mat homspace::calcop_cols(string opname, long p, const vec& jlist, const matop& mlist,
682+
mat homspace::calcop_cols(string opname, long p, const vec_i& jlist, const matop& mlist,
683683
int display) const
684684
{
685685
int i, d = dim(jlist);
@@ -704,7 +704,7 @@ svec homspace::s_calcop_col(string opname, long p, int j, const matop& mlist,
704704
return colj;
705705
}
706706

707-
smat homspace::s_calcop_cols(string opname, long p, const vec& jlist, const matop& mlist,
707+
smat homspace::s_calcop_cols(string opname, long p, const vec_i& jlist, const matop& mlist,
708708
int display) const
709709
{
710710
int i, d = dim(jlist);
@@ -765,7 +765,7 @@ vec homspace::heckeop_col(long p, int j, int display) const
765765
return calcop_col(name,p,j,matlist,display);
766766
}
767767

768-
mat homspace::heckeop_cols(long p, const vec& jlist, int display) const
768+
mat homspace::heckeop_cols(long p, const vec_i& jlist, int display) const
769769
{
770770
matop matlist(p,modulus);
771771
string name = ((modulus%p) ? T_opname : W_opname);
@@ -779,7 +779,7 @@ svec homspace::s_heckeop_col(long p, int j, int display) const
779779
return s_calcop_col(name,p,j,matlist,display);
780780
}
781781

782-
smat homspace::s_heckeop_cols(long p, const vec& jlist, int display) const
782+
smat homspace::s_heckeop_cols(long p, const vec_i& jlist, int display) const
783783
{
784784
matop matlist(p,modulus);
785785
string name = ((modulus%p) ? T_opname : W_opname);
@@ -861,7 +861,7 @@ vec homspace::conj_col(int j, int display) const
861861
return colj;
862862
}
863863

864-
mat homspace::conj_cols(const vec& jlist, int display) const
864+
mat homspace::conj_cols(const vec_i& jlist, int display) const
865865
{
866866
int d = dim(jlist);
867867
mat m(d,rk);
@@ -883,7 +883,7 @@ svec homspace::s_conj_col(int j, int display) const
883883
return colj;
884884
}
885885

886-
smat homspace::s_conj_cols(const vec& jlist, int display) const
886+
smat homspace::s_conj_cols(const vec_i& jlist, int display) const
887887
{
888888
int d = dim(jlist);
889889
smat m(d,rk);
@@ -1011,7 +1011,7 @@ vec homspace::opmat_col(int i, int j, int v)
10111011
return ans;
10121012
}
10131013

1014-
mat homspace::opmat_cols(int i, const vec& jlist, int v)
1014+
mat homspace::opmat_cols(int i, const vec_i& jlist, int v)
10151015
{
10161016
if(i==-1) return conj_cols(jlist,v);
10171017
int d = dim(jlist);
@@ -1056,7 +1056,7 @@ svec homspace::s_opmat_col(int i, int j, int v)
10561056
return ans;
10571057
}
10581058

1059-
smat homspace::s_opmat_cols(int i, const vec& jlist, int v)
1059+
smat homspace::s_opmat_cols(int i, const vec_i& jlist, int v)
10601060
{
10611061
if(i==-1) return s_conj_cols(jlist,v);
10621062
int d = dim(jlist);

libsrc/mat.cc

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1444,11 +1444,7 @@ mat ref_via_flint(const mat& M, vec_i& pcols, vec_i& npcols,
14441444
long i, j, k;
14451445

14461446
#ifdef TRACE_FLINT_RREF
1447-
#if (SCALAR_OPTION==1)
1448-
cout << "In ref_via_flint(M) with M having "<<nr<<" rows and "<<nc<<" columns, using hmod_mat and modulus "<<pr<<"."<<endl;
1449-
#else
1450-
cout << "In ref_via_flint(M) with M having "<<nr<<" rows and "<<nc<<" columns, using nmod_mat and modulus "<<pr<<"."<<endl;
1451-
#endif
1447+
cout << "In ref_via_flint(M) with M having "<<nr<<" rows and "<<nc<<" columns, using mod_mat and modulus "<<pr<<"."<<endl;
14521448
// cout << "Size of scalar = "<<8*sizeof(scalar)<<" bits"<<endl;
14531449
// cout << "Size of uscalar = "<<8*sizeof(uscalar)<<" bits"<<endl;
14541450
#endif
@@ -1581,7 +1577,7 @@ double sparsity(const mat& m)
15811577
return double(population(m))/m.entries.size();
15821578
}
15831579

1584-
#if (FLINT==1)&&(__FLINT_VERSION>2)&&(SCALAR_OPTION==1)
1580+
#if (FLINT==1)&&(__FLINT_VERSION>2)&&defined(scalar_is_int)
15851581

15861582
// Implementation of wrapper functions declared in flinterface.h
15871583
// written by Fredrik Johansson
@@ -1590,22 +1586,22 @@ double sparsity(const mat& m)
15901586
#include <flint/gr_mat.h>
15911587

15921588
void
1593-
hmod_mat_init(hmod_mat_t mat, slong rows, slong cols, hlimb_t n)
1589+
hmod_mat_init(hmod_mat_t A, slong rows, slong cols, hlimb_t n)
15941590
{
15951591
gr_ctx_t ctx;
15961592
gr_ctx_init_nmod32(ctx, n);
1597-
gr_mat_init((gr_mat_struct *) mat, rows, cols, ctx);
1598-
nmod_init(&(mat->mod), n);
1593+
gr_mat_init((gr_mat_struct *) A, rows, cols, ctx);
1594+
nmod_init(&(A->mod), n);
15991595
}
16001596

16011597
void
1602-
hmod_mat_clear(hmod_mat_t mat)
1598+
hmod_mat_clear(hmod_mat_t A)
16031599
{
1604-
if (mat->entries)
1600+
if (A->entries)
16051601
{
1606-
flint_free(mat->entries);
1602+
flint_free(A->entries);
16071603
#if (__FLINT_VERSION==3)&&(__FLINT_VERSION_MINOR<3)
1608-
flint_free(mat->rows);
1604+
flint_free(A->rows);
16091605
#endif
16101606
}
16111607
}
@@ -1619,12 +1615,12 @@ hmod_mat_mul(hmod_mat_t C, const hmod_mat_t A, const hmod_mat_t B)
16191615
}
16201616

16211617
slong
1622-
hmod_mat_rref(hmod_mat_t mat)
1618+
hmod_mat_rref(hmod_mat_t A)
16231619
{
16241620
slong rank;
16251621
gr_ctx_t ctx;
1626-
gr_ctx_init_nmod32(ctx, mat->mod.n);
1627-
GR_MUST_SUCCEED(gr_mat_rref_lu(&rank, (gr_mat_struct *) mat, (gr_mat_struct *) mat, ctx));
1622+
gr_ctx_init_nmod32(ctx, A->mod.n);
1623+
GR_MUST_SUCCEED(gr_mat_rref_lu(&rank, (gr_mat_struct *) A, (gr_mat_struct *) A, ctx));
16281624
return rank;
16291625
}
16301626

libsrc/matrix.cc

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,49 +27,47 @@
2727
#undef vec
2828
#undef mat
2929
#undef subspace
30-
#undef SCALAR_OPTION
3130

3231
#define scalar int
3332
#define vec vec_i
3433
#define mat mat_i
3534
#define subspace subspace_i
36-
#define SCALAR_OPTION 1
35+
#define scalar_is_int
3736

3837
#include "mat.cc"
3938

4039
#undef scalar
4140
#undef vec
4241
#undef mat
4342
#undef subspace
44-
#undef SCALAR_OPTION
43+
#undef scalar_is_int
4544

4645
#define scalar long
4746
#define vec vec_l
4847
#define mat mat_l
4948
#define subspace subspace_l
50-
#define SCALAR_OPTION 2
5149

5250
#include "mat.cc"
5351

5452
#undef scalar
5553
#undef vec
5654
#undef mat
5755
#undef subspace
58-
#undef SCALAR_OPTION
5956

6057
#define scalar bigint
6158
#define vec vec_m
6259
#define mat mat_m
6360
#define subspace subspace_m
64-
#define SCALAR_OPTION 0
6561

6662
#include "mat.cc"
6763

6864
#undef scalar
6965
#undef vec
7066
#undef mat
7167
#undef subspace
72-
#undef SCALAR_OPTION
68+
69+
// The following functions are here and not in mat.cc since they are
70+
// not to be created in 3 versions
7371

7472
mat_m to_mat_m(const mat_i& m)
7573
{

0 commit comments

Comments
 (0)