We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ae9083e commit be415a9Copy full SHA for be415a9
libsrc/eclib/matrix.h
@@ -86,10 +86,19 @@
86
#undef smat
87
#undef smat_elim
88
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);
+// conversions between matrices of different scalar types
+
+mat_m to_mat_m(const mat_i& m);
+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
101
+inline mat_l to_mat_l(const mat_l& m) {return m;}
102
103
#endif
104
libsrc/eclib/splitbase.h
@@ -53,11 +53,11 @@ class splitter_base {
53
public:
54
virtual mat opmat(int,int,int=0) = 0;
55
virtual vec opmat_col(int i, int j, int verb=0) = 0;
56
- virtual mat opmat_cols(int i, const vec& jlist, int verb=0) = 0;
+ virtual mat opmat_cols(int i, const vec_i& jlist, int verb=0) = 0;
57
virtual mat opmat_restricted(int,const subspace& s, int,int=0) = 0;
58
virtual smat s_opmat(int,int,int=0) = 0;
59
virtual svec s_opmat_col(int i, int j, int verb=0) = 0;
60
- virtual smat s_opmat_cols(int i, const vec& jlist, int verb=0) = 0;
+ virtual smat s_opmat_cols(int i, const vec_i& jlist, int verb=0) = 0;
61
virtual smat s_opmat_restricted(int,const ssubspace& s, int, int=0) = 0;
62
virtual long matdim(void) = 0;
63
virtual scalar matden(void) = 0;
libsrc/eclib/vector.h
@@ -95,9 +95,18 @@ class subspace_i; class subspace_l; class subspace_m;
+// conversions between vectors of different scalar types
vec_m to_vec_m(const vec_i& v);
vec_m to_vec_m(const vec_l& v);
-vec_i to_vec_i(const vec_m& v);
+inline vec_m to_vec_m(const vec_m& v) {return v;}
+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);
110
+vec_i to_vec_i(const vec_m& v);
111
112
libsrc/matrix.cc
@@ -94,6 +94,15 @@ mat_i to_mat_i(const mat_m& m)
return mat_i(m.nrows(), m.ncols(), n);
}
+mat_i to_mat_i(const mat_l& m)
+{
+ const vector<long> & mij = m.get_entries();
+ auto toint = [](const long& a) {return int(a);};
+ vector<int> n(mij.size());
+ std::transform(mij.begin(), mij.end(), n.begin(), toint);
+ return mat_i(m.nrows(), m.ncols(), n);
+}
mat_l to_mat_l(const mat_m& m)
{
const vector<bigint> & mij = m.get_entries();
@@ -102,3 +111,12 @@ mat_l to_mat_l(const mat_m& m)
std::transform(mij.begin(), mij.end(), n.begin(), tolong);
return mat_l(m.nrows(), m.ncols(), n);
113
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
@@ -81,39 +81,39 @@ int xsqrt(bigfloat a, bigfloat &b)
81
82
vector<long> rank1::qeps(const quartic& q, int x2)
83
84
- vector<long> vec(num_aux); // position 0 is not used
85
- long i; vec[0]=0;
+ vector<long> v(num_aux); // position 0 is not used
+ long i; v[0]=0;
for(i=1; i<num_aux; i++)
long a = posmod(q.geta(),auxs[i]);
long H = posmod(q.getH(),auxs[i]);
if(x2) H=posmod(hscalemod[i]*H,auxs[i]);
- vec[i] = flags[i][a][H];
+ v[i] = flags[i][a][H];
- return vec;
+ return v;
-void rank1::show_eps_vec(const vector<long>& vec)
+void rank1::show_eps_vec(const vector<long>& v)
long i;
cout<<"(";
for(i=1; i<num_aux; i++) {
if(i>1) cout<<":";
if(aux_types[i]==1)
- switch(vec[i]) {
+ switch(v[i]) {
case 15: cout<<"0"; break;
case 5: cout<<"1"; break;
default: cout<<"?";
else
case 15: cout<<"00"; break;
case 5: cout<<"01"; break;
case 3: cout<<"10"; break;
case 1: cout<<"11"; break;
default: cout<<"??";
- // cout<<"("<<vec[i]<<")";
+ // cout<<"("<<v[i]<<")";
cout<<")";
libsrc/vector.cc
@@ -97,6 +97,15 @@ vec_i to_vec_i(const vec_m& v)
return vec_i(w);
+vec_i to_vec_i(const vec_l& v)
+ const vector<long> & vi = v.get_entries();
+ vector<int> w(vi.size());
+ std::transform(vi.begin(), vi.end(), w.begin(), toint);
+ return vec_i(w);
vec_l to_vec_l(const vec_m& v)
const vector<bigint> & vi = v.get_entries();
@@ -105,3 +114,12 @@ vec_l to_vec_l(const vec_m& v)
std::transform(vi.begin(), vi.end(), w.begin(), tolong);
return vec_l(w);
+vec_l to_vec_l(const vec_i& v)
+ const vector<int> & vi = v.get_entries();
+ vector<long> w(vi.size());
123
+ std::transform(vi.begin(), vi.end(), w.begin(), tolong);
124
+ return vec_l(w);
125
0 commit comments