Skip to content

Commit d18a52a

Browse files
committed
minor refactoring of vec/mat code
1 parent 5918854 commit d18a52a

File tree

6 files changed

+15
-69
lines changed

6 files changed

+15
-69
lines changed

libsrc/eclib/matrix.h

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -86,19 +86,10 @@
8686
#undef smat
8787
#undef smat_elim
8888

89-
// conversions between matrices of different scalar types
90-
91-
mat_m to_mat_m(const mat_i& m);
92-
mat_m to_mat_m(const mat_l& m);
93-
inline mat_m to_mat_m(const mat_m& m) {return m;}
94-
95-
mat_i to_mat_i(const mat_m& m);
96-
mat_i to_mat_i(const mat_l& m);
97-
inline mat_i to_mat_i(const mat_i& m) {return m;}
98-
99-
mat_l to_mat_l(const mat_m& m);
100-
mat_l to_mat_l(const mat_m& m);
101-
inline mat_l to_mat_l(const mat_l& m) {return m;}
89+
mat_m to_mat_m(const mat_i& v);
90+
mat_m to_mat_m(const mat_l& v);
91+
mat_i to_mat_i(const mat_m& v);
92+
mat_l to_mat_l(const mat_m& v);
10293

10394
#endif
10495

libsrc/eclib/splitbase.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ class splitter_base {
5353
public:
5454
virtual mat opmat(int,int,int=0) = 0;
5555
virtual vec opmat_col(int i, int j, int verb=0) = 0;
56-
virtual mat opmat_cols(int i, const vec_i& jlist, int verb=0) = 0;
56+
virtual mat opmat_cols(int i, const vec& jlist, int verb=0) = 0;
5757
virtual mat opmat_restricted(int,const subspace& s, int,int=0) = 0;
5858
virtual smat s_opmat(int,int,int=0) = 0;
5959
virtual svec s_opmat_col(int i, int j, int verb=0) = 0;
60-
virtual smat s_opmat_cols(int i, const vec_i& jlist, int verb=0) = 0;
60+
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;
6363
virtual scalar matden(void) = 0;

libsrc/eclib/vector.h

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -95,18 +95,9 @@ class subspace_i; class subspace_l; class subspace_m;
9595
#undef smat
9696
#undef smat_elim
9797

98-
// conversions between vectors of different scalar types
99-
10098
vec_m to_vec_m(const vec_i& v);
10199
vec_m to_vec_m(const vec_l& v);
102-
inline vec_m to_vec_m(const vec_m& v) {return v;}
103-
104-
vec_l to_vec_l(const vec_i& v);
105-
inline vec_l to_vec_l(const vec_l& v) {return v;}
106-
vec_l to_vec_l(const vec_m& v);
107-
108-
inline vec_i to_vec_i(const vec_i& v) {return v;}
109-
vec_i to_vec_i(const vec_l& v);
110100
vec_i to_vec_i(const vec_m& v);
101+
vec_l to_vec_l(const vec_m& v);
111102

112103
#endif

libsrc/matrix.cc

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,6 @@ mat_i to_mat_i(const mat_m& m)
9494
return mat_i(m.nrows(), m.ncols(), n);
9595
}
9696

97-
mat_i to_mat_i(const mat_l& m)
98-
{
99-
const vector<long> & mij = m.get_entries();
100-
auto toint = [](const long& a) {return int(a);};
101-
vector<int> n(mij.size());
102-
std::transform(mij.begin(), mij.end(), n.begin(), toint);
103-
return mat_i(m.nrows(), m.ncols(), n);
104-
}
105-
10697
mat_l to_mat_l(const mat_m& m)
10798
{
10899
const vector<bigint> & mij = m.get_entries();
@@ -111,12 +102,3 @@ mat_l to_mat_l(const mat_m& m)
111102
std::transform(mij.begin(), mij.end(), n.begin(), tolong);
112103
return mat_l(m.nrows(), m.ncols(), n);
113104
}
114-
115-
mat_l to_mat_l(const mat_i& m)
116-
{
117-
const vector<int> & mij = m.get_entries();
118-
auto tolong = [](const int& a) {return long(a);};
119-
vector<long> n(mij.size());
120-
std::transform(mij.begin(), mij.end(), n.begin(), tolong);
121-
return mat_l(m.nrows(), m.ncols(), n);
122-
}

libsrc/mrank1.cc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,39 +81,39 @@ int xsqrt(bigfloat a, bigfloat &b)
8181

8282
vector<long> rank1::qeps(const quartic& q, int x2)
8383
{
84-
vector<long> v(num_aux); // position 0 is not used
85-
long i; v[0]=0;
84+
vector<long> vec(num_aux); // position 0 is not used
85+
long i; vec[0]=0;
8686
for(i=1; i<num_aux; i++)
8787
{
8888
long a = posmod(q.geta(),auxs[i]);
8989
long H = posmod(q.getH(),auxs[i]);
9090
if(x2) H=posmod(hscalemod[i]*H,auxs[i]);
91-
v[i] = flags[i][a][H];
91+
vec[i] = flags[i][a][H];
9292
}
93-
return v;
93+
return vec;
9494
}
9595

96-
void rank1::show_eps_vec(const vector<long>& v)
96+
void rank1::show_eps_vec(const vector<long>& vec)
9797
{
9898
long i;
9999
cout<<"(";
100100
for(i=1; i<num_aux; i++) {
101101
if(i>1) cout<<":";
102102
if(aux_types[i]==1)
103-
switch(v[i]) {
103+
switch(vec[i]) {
104104
case 15: cout<<"0"; break;
105105
case 5: cout<<"1"; break;
106106
default: cout<<"?";
107107
}
108108
else
109-
switch(v[i]) {
109+
switch(vec[i]) {
110110
case 15: cout<<"00"; break;
111111
case 5: cout<<"01"; break;
112112
case 3: cout<<"10"; break;
113113
case 1: cout<<"11"; break;
114114
default: cout<<"??";
115115
}
116-
// cout<<"("<<v[i]<<")";
116+
// cout<<"("<<vec[i]<<")";
117117
}
118118
cout<<")";
119119
}

libsrc/vector.cc

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,6 @@ vec_i to_vec_i(const vec_m& v)
9797
return vec_i(w);
9898
}
9999

100-
vec_i to_vec_i(const vec_l& v)
101-
{
102-
const vector<long> & vi = v.get_entries();
103-
auto toint = [](const long& a) {return int(a);};
104-
vector<int> w(vi.size());
105-
std::transform(vi.begin(), vi.end(), w.begin(), toint);
106-
return vec_i(w);
107-
}
108-
109100
vec_l to_vec_l(const vec_m& v)
110101
{
111102
const vector<bigint> & vi = v.get_entries();
@@ -114,12 +105,3 @@ vec_l to_vec_l(const vec_m& v)
114105
std::transform(vi.begin(), vi.end(), w.begin(), tolong);
115106
return vec_l(w);
116107
}
117-
118-
vec_l to_vec_l(const vec_i& v)
119-
{
120-
const vector<int> & vi = v.get_entries();
121-
auto tolong = [](const int& a) {return long(a);};
122-
vector<long> w(vi.size());
123-
std::transform(vi.begin(), vi.end(), w.begin(), tolong);
124-
return vec_l(w);
125-
}

0 commit comments

Comments
 (0)