Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion M2/Macaulay2/e/NAG/NAG.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ inline const CCC* cast_to_CCC(const Ring* R)
inline ring_elem from_doubles(const CCC* C, double re, double im)
{
M2::ARingCC::Element a(C->ring());
C->ring().set_from_doubles(a, re, im);
C->ring().set(a, re, im);
ring_elem result;
C->ring().to_ring_elem(result, a);
return result;
Expand Down
22 changes: 11 additions & 11 deletions M2/Macaulay2/e/SLP/SLP-imp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ void SLEvaluatorConcrete<RT>::computeNextNode()
switch (*nIt++)
{
case SLProgram::MProduct:
ring().set_from_long(v, 1);
ring().set(v, 1);
for (int i = 0; i < *numInputsIt; i++)
ring().mult(v, v, *(vIt + (*inputPositionsIt++)));
numInputsIt++;
Expand Down Expand Up @@ -418,13 +418,13 @@ bool HomotopyConcrete<RT, FixedPrecisionHomotopyAlgorithm>::track(
typedef MatElementaryOps<DMat<RT> > MatOps;

RealElement t_step(R), min_step2(R), epsilon2(R), infinity_threshold2(R);
R.set_from_BigReal(t_step, init_dt); // initial step
R.set_from_BigReal(min_step2, min_dt);
R.set(t_step, init_dt); // initial step
R.set(min_step2, min_dt);
R.mult(min_step2, min_step2, min_step2); // min_step^2
R.set_from_BigReal(epsilon2, epsilon);
R.set(epsilon2, epsilon);
int tolerance_bits = int(log2(fabs(R.coerceToDouble(epsilon2))));
R.mult(epsilon2, epsilon2, epsilon2); // epsilon^2
R.set_from_BigReal(infinity_threshold2, infinity_threshold);
R.set(infinity_threshold2, infinity_threshold);
R.mult(infinity_threshold2, infinity_threshold2, infinity_threshold2);
int num_successes_before_increase = 3;

Expand All @@ -433,10 +433,10 @@ bool HomotopyConcrete<RT, FixedPrecisionHomotopyAlgorithm>::track(
// constants
RealElement one(R), two(R), four(R), six(R), one_half(R), one_sixth(R);
RealElementType& dt_factor = one_half;
R.set_from_long(one, 1);
R.set_from_long(two, 2);
R.set_from_long(four, 4);
R.set_from_long(six, 6);
R.set(one, 1);
R.set(two, 2);
R.set(four, 4);
R.set(six, 6);
R.divide(one_half, one, two);
R.divide(one_sixth, one, six);

Expand Down Expand Up @@ -749,8 +749,8 @@ bool HomotopyConcrete<RT, FixedPrecisionHomotopyAlgorithm>::track(
for (size_t i = 0; i <= n; i++) C.set(ou.entry(i, s), x0c0.entry(i, 0));
C.set(ou.entry(n + 1, s), dc); // store last increment attempted
if (status == PROCESSING) status = REGULAR;
oe.ring().set_from_long(oe.entry(0, s), status);
oe.ring().set_from_long(oe.entry(1, s), count);
oe.ring().set(oe.entry(0, s), status);
oe.ring().set(oe.entry(1, s), count);
}

std::chrono::steady_clock::time_point end = std::chrono::steady_clock::now();
Expand Down
8 changes: 4 additions & 4 deletions M2/Macaulay2/e/basic-mutable-matrices/dmat-lu-inplace.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ inline size_t DMatLUinPlace<M2::ARingRRR>::findPivot(size_t row, size_t col)
if (ring().compare_elems(abs, largest) > 0)
{
best_row_so_far = i;
ring().set(largest, abs);
ring().copy(largest, abs);
}
}
return best_row_so_far;
Expand Down Expand Up @@ -388,14 +388,14 @@ void LUUtil<RingType>::setUpperLower(const Mat& LU, Mat& lower, Mat& upper)

for (size_t c = 0; c < LU.numColumns(); c++)
{
if (c < min) LU.ring().set_from_long(lower.entry(c, c), 1);
if (c < min) LU.ring().set(lower.entry(c, c), 1);
for (size_t r = 0; r < LU.numRows(); r++)
{
if (r <= c)
LU.ring().set(upper.entry(r, c), LU.entry(r, c));
LU.ring().copy(upper.entry(r, c), LU.entry(r, c));
else if (c < lower.numRows())
{
LU.ring().set(lower.entry(r, c), LU.entry(r, c));
LU.ring().copy(lower.entry(r, c), LU.entry(r, c));
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions M2/Macaulay2/e/basic-mutable-matrices/dmat-lu-qq.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class DMatLinAlg<M2::ARingQQ>
// fmpq_init(b);
// for (size_t c = 0; c < LU.numColumns(); c++)
// {
// if (c < min) L.ring().set_from_long(L.entry(c, c), 1);
// if (c < min) L.ring().set(L.entry(c, c), 1);
// for (size_t r = 0; r < LU.numRows(); r++)
// {
// if (r <= c)
Expand All @@ -131,8 +131,8 @@ class DMatLinAlg<M2::ARingQQ>

// fmpq_set_fmpz_frac(b, fmpz_mat_entry(LU.value(), r, c), den);
// flint_mpq_init_set_readonly(a, b);
// assert(U.ring().set_from_mpq(U.entry(r, c), a));
// U.ring().set_from_mpq(U.entry(r, c), a); // ignore the result
// assert(U.ring().set(U.entry(r, c), a));
// U.ring().set(U.entry(r, c), a); // ignore the result
// // boolean: this
// // operation should
// // not fail
Expand All @@ -143,7 +143,7 @@ class DMatLinAlg<M2::ARingQQ>
// mpz_t a;
// flint_mpz_init_set_readonly(a,
// fmpz_mat_entry(LU.value(), r, c));
// L.ring().set_from_mpz(L.entry(r, c), a);
// L.ring().set(L.entry(r, c), a);
// flint_mpz_clear_readonly(a);
// }
// }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class DMatLinAlg<M2::ARingZZpFlint>
// Fill in this column
for (long r = 0; r < profile.size(); r++)
{
mMatrix.ring().set(X.entry(profile[r], c), AB.entry(r, ncols + c));
mMatrix.ring().copy(X.entry(profile[r], c), AB.entry(r, ncols + c));
}
}
return true;
Expand Down
36 changes: 18 additions & 18 deletions M2/Macaulay2/e/basic-mutable-matrices/dmat-lu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,19 +212,19 @@ void DMatLinAlg<RingType>::setUpperLower(const Mat& LU, Mat& lower, Mat& upper)
for (size_t r=0; r<=c; r++)
{
if (r >= upper.numRows()) break;
upper.ring().set(*U1, *LUraw++);
upper.ring().copy(*U1, *LUraw++);
U1 += upper.numColumns();
}
U++; // change to next column

if (c < lower.numColumns())
{
lower.ring().set_from_long(*L, 1); // diagonal entry of L should be 1
lower.ring().set(*L, 1); // diagonal entry of L should be 1
L += lower.numColumns(); // pointing to entry right below diagonal
auto L1 = L; // will increment by lower.numRows() each loop here
for (size_t r=c+1; r<lower.numRows(); r++)
{
lower.ring().set(*L1, *LUraw++);
lower.ring().copy(*L1, *LUraw++);
L1 += lower.numColumns(); // to place next entry.
}
L++; // change to next column
Expand All @@ -245,14 +245,14 @@ void DMatLinAlg<RingType>::setUpperLower(const Mat& LU, Mat& lower, Mat& upper)

for (size_t c = 0; c < LU.numColumns(); c++)
{
if (c < min) ring().set_from_long(lower.entry(c, c), 1);
if (c < min) ring().set(lower.entry(c, c), 1);
for (size_t r = 0; r < LU.numRows(); r++)
{
if (r <= c)
ring().set(upper.entry(r, c), LU.entry(r, c));
ring().copy(upper.entry(r, c), LU.entry(r, c));
else if (c < lower.numRows())
{
ring().set(lower.entry(r, c), LU.entry(r, c));
ring().copy(lower.entry(r, c), LU.entry(r, c));
}
}
}
Expand All @@ -278,9 +278,9 @@ void DMatLinAlg<RingType>::determinant(ElementType& result)
assert(LU.numRows() == LU.numColumns());

if (mLUObject.signOfPermutation())
ring().set_from_long(result, 1);
ring().set(result, 1);
else
ring().set_from_long(result, -1);
ring().set(result, -1);
for (size_t i = 0; i < LU.numRows(); i++)
ring().mult(result, result, LU.entry(i, i));
}
Expand Down Expand Up @@ -345,15 +345,15 @@ bool DMatLinAlg<RingType>::solve(const Mat& B, Mat& X)

// Step 1: set b to be the permuted i-th column of B.
for (size_t r = 0; r < B.numRows(); r++)
ring().set(b[r], B.entry(perm[r], col));
ring().copy(b[r], B.entry(perm[r], col));

/// printf("b:\n");
/// debug_out_list(b, LU.numRows());

// Step 2: Solve Ly=b
for (size_t i = 0; i < rk; i++)
{
ring().set(y[i], b[i]);
ring().copy(y[i], b[i]);
for (size_t j = 0; j < i; j++)
{
ring().mult(tmp, LU.entry(i, j), y[j]);
Expand All @@ -367,7 +367,7 @@ bool DMatLinAlg<RingType>::solve(const Mat& B, Mat& X)
// Step 2B: see if the solution is consistent
for (size_t i = rk; i < LU.numRows(); i++)
{
ring().set(tmp, b[i]);
ring().copy(tmp.value(), b[i]);
for (size_t j = 0; j < rk; j++)
{
ring().mult(tmp2, LU.entry(i, j), y[j]);
Expand All @@ -386,14 +386,14 @@ bool DMatLinAlg<RingType>::solve(const Mat& B, Mat& X)
// and place x back into X as col-th column
for (long i = rk - 1; i >= 0; --i)
{
ring().set(x[i], y[i]);
ring().copy(x[i], y[i]);
for (size_t j = i + 1; j <= rk - 1; j++)
{
ring().mult(tmp, LU.entry(i, pivotColumns[j]), x[j]);
ring().subtract(x[i], x[i], tmp);
}
ring().divide(x[i], x[i], LU.entry(i, pivotColumns[i]));
ring().set(X.entry(pivotColumns[i], col), x[i]);
ring().copy(X.entry(pivotColumns[i], col), x[i]);

/// buffer o;
/// printf("after i=%ld\n", i);
Expand Down Expand Up @@ -436,7 +436,7 @@ void permuteRows(const Mat& B,
B.numColumns()); // leaves B alone if correct size already...
for (long r = 0; r < B.numRows(); r++)
for (long c = 0; c < B.numColumns(); c++)
B.ring().set(result.entry(r, c), B.entry(permutation[r], c));
B.ring().copy(result.entry(r, c), B.entry(permutation[r], c));
}

template <class Mat>
Expand Down Expand Up @@ -535,7 +535,7 @@ bool DMatLinAlg<RingType>::inverse(Mat& X)

Mat id(ring(), LU.numRows(), LU.numRows());
for (size_t i = 0; i < LU.numRows(); i++)
ring().set_from_long(id.entry(i, i), 1);
ring().set(id.entry(i, i), 1);

solve(id, X);
return true;
Expand Down Expand Up @@ -569,13 +569,13 @@ size_t DMatLinAlg<RingType>::kernel(Mat& X)
continue;
}
// At this point, we are ready to create a column of X.
ring().set_from_long(X.entry(col, colX), -1);
ring().set(X.entry(col, colX), -1);
// Now we loop through and set the elements in the rows of X = pivot
// columns.
for (long p = nextpivotidx - 1; p >= 0; p--)
{
// set X.entry(pivotColumns[p], colX)
ring().set(tmp, LU.entry(p, col));
ring().copy(tmp.value(), LU.entry(p, col));
for (size_t i = nextpivotidx - 1; i >= p + 1; i--)
{
ring().mult(tmp2,
Expand All @@ -584,7 +584,7 @@ size_t DMatLinAlg<RingType>::kernel(Mat& X)
ring().subtract(tmp, tmp, tmp2);
}
ring().divide(tmp, tmp, LU.entry(p, pivotColumns[p]));
ring().set(X.entry(pivotColumns[p], colX), tmp);
ring().copy(X.entry(pivotColumns[p], colX), tmp.value());
}
colX++;
col++;
Expand Down
8 changes: 4 additions & 4 deletions M2/Macaulay2/e/basic-mutable-matrices/dmat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ void addMultipleTo(DMatZZpFFPACK& C,

DMatZZpFFPACK::ElementType b;
C.ring().init(b);
C.ring().set_from_long(b, 1);
C.ring().set(b, 1);
FFLAS::fgemm(C.ring().field(),
tB,
tA,
Expand All @@ -55,7 +55,7 @@ void addMultipleTo(DMatZZpFFPACK& C,
const DMatZZpFFPACK& B)
{
DMatZZpFFPACK::ElementType one;
A.ring().set_from_long(one, 1);
A.ring().set(one, 1);

addMultipleTo(C, one, A, B);
}
Expand All @@ -65,7 +65,7 @@ void subtractMultipleTo(DMatZZpFFPACK& C,
const DMatZZpFFPACK& B)
{
DMatZZpFFPACK::ElementType minus_one;
A.ring().set_from_long(minus_one, -1);
A.ring().set(minus_one, -1);
addMultipleTo(C, minus_one, A, B);
}

Expand Down Expand Up @@ -96,7 +96,7 @@ void determinant(const DMatZZpFFPACK& mat, ZZpFFPACK::ElementType& result_det)
{
// 26 April 2014: this branch is needed as FFPACK gives answer of 0 in
// this case.
mat.ring().set_from_long(result_det, 1);
mat.ring().set(result_det, 1);
}
else
{
Expand Down
20 changes: 10 additions & 10 deletions M2/Macaulay2/e/basic-mutable-matrices/lapack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ void fill_from_lapack_upper(const std::vector<double>& lapack_numbers, // colum
for (size_t r = 0; r <= c; ++r)
{
if (r >= upper.numRows()) break;
upper.ring().set_from_doubles(upper.entry(r, c), U[2*r], U[2*r+1]);
upper.ring().set(upper.entry(r, c), U[2*r], U[2*r+1]);
}
}

Expand Down Expand Up @@ -176,16 +176,16 @@ void fill_lower_and_upper(const std::vector<double>& lapack_numbers, // column-
{
double re = *U++;
double im = *U++;
ring.set_from_doubles(upper.entry(r, c), re, im);
ring.set(upper.entry(r, c), re, im);
// upper.entry(r, c).re = *U++;
// upper.entry(r, c).im = *U++;
}
ring.set_from_long(lower.entry(c, c), 1);
ring.set(lower.entry(c, c), 1);
for (size_t r = c+1 ; r <= lower.numColumns(); ++r)
{
double re = *U++;
double im = *U++;
ring.set_from_doubles(lower.entry(r, c), re, im);
ring.set(lower.entry(r, c), re, im);
// lower.entry(r,c).re = *U++;
// lower.entry(r,c).im = *U++;
}
Expand Down Expand Up @@ -353,7 +353,7 @@ bool Lapack::eigenvalues(const DMatRR *A, DMatCC *eigvals)
{
eigvals->resize(size, 1);
for (int i = 0; i < size; i++)
eigvals->ring().set_from_doubles(eigvals->entry(i, 0), real[i], imag[i]);
eigvals->ring().set(eigvals->entry(i, 0), real[i], imag[i]);
}

delete [] real;
Expand Down Expand Up @@ -427,7 +427,7 @@ bool Lapack::eigenvectors(const DMatRR *A,
double* eigenLoc = eigen; // current row (eigenvector) in the eigen array
for (int j = 0; j < size; j++, eigenLoc += size)
{
eigvals->ring().set_from_doubles(eigvals->entry(j,0), real[j], imag[j]);
eigvals->ring().set(eigvals->entry(j,0), real[j], imag[j]);

// now set j-th column of eigvecs
if (imag[j] == 0)
Expand All @@ -442,9 +442,9 @@ bool Lapack::eigenvectors(const DMatRR *A,
{
for (int i = 0; i < size; ++i)
{
eigvecs->ring().set_from_doubles(eigvecs->entry(i,j),
eigvecs->ring().set(eigvecs->entry(i,j),
eigenLoc[i], eigenLoc[size + i]);
eigvecs->ring().set_from_doubles(eigvecs->entry(i,j+1),
eigvecs->ring().set(eigvecs->entry(i,j+1),
eigenLoc[i], - eigenLoc[size + i]);
}
}
Expand Down Expand Up @@ -1710,7 +1710,7 @@ bool Lapack::least_squares(const DMatCC *A, const DMatCC *b, DMatCC *x)
{
double re = copyb[copyloc++];
double im = copyb[copyloc++];
x->ring().set_from_doubles(x->entry(i,j), re, im);
x->ring().set(x->entry(i,j), re, im);
}
}
}
Expand Down Expand Up @@ -1811,7 +1811,7 @@ bool Lapack::least_squares_deficient(const DMatCC *A,
{
double re = copyb[copyloc++];
double im = copyb[copyloc++];
x->ring().set_from_doubles(x->entry(i,j), re, im);
x->ring().set(x->entry(i,j), re, im);
}
}
}
Expand Down
Loading