Skip to content
Snippets Groups Projects
Commit 6755f815 authored by Antoine Lucas's avatar Antoine Lucas
Browse files

cleanup and fix gcc warnings

parent 3d2ca4da
No related branches found
No related tags found
No related merge requests found
......@@ -450,7 +450,7 @@ bigvec bigintegerR::biginteger_get_at_C(bigvec va, SEXP ind)
bigvec result;
for(unsigned int i = 0 ; i < v_ind.size(); i++){
int indice = v_ind[i];
if(indice < va.size()){
if(indice < (int) va.size()){
result.push_back(va[indice]);
} else {
result.push_back(bigmod());
......@@ -467,7 +467,7 @@ SEXP biginteger_set_at(SEXP src, SEXP idx, SEXP value)
bigvec vvalue = bigintegerR::create_bignum(value);
bigvec result = bigintegerR::create_bignum(src);
vector<int> vidx = extract_gmp_R::indice_set_at(result.size(),idx);
vector<int> vidx = extract_gmp_R::indice_get_at(result.size(),idx);
if(vidx.size() == 0) {
......@@ -480,8 +480,8 @@ SEXP biginteger_set_at(SEXP src, SEXP idx, SEXP value)
int pos = 0;
for(int i = 0 ; i < vidx.size(); i++){
while(result.size() <= (vidx[i] )) {
for(unsigned int i = 0 ; i < vidx.size(); i++){
while(result.size() <=(unsigned int) (vidx[i] )) {
result.push_back(bigmod());
}
result.set(vidx[i],vvalue[pos++ % vvalue.size()]);
......
......@@ -437,7 +437,7 @@ SEXP bigrational_get_at(SEXP a, SEXP b)
for(unsigned int i = 0 ; i < v_ind.size(); i++){
int indice = v_ind[i];
if(indice < va.size()){
if(indice < (int) va.size()){
result.push_back(va[indice]);
} else {
result.push_back(bigrational());
......@@ -451,7 +451,7 @@ SEXP bigrational_set_at(SEXP src, SEXP idx, SEXP value)
{
bigvec_q vvalue = bigrationalR::create_bignum(value);
bigvec_q result = bigrationalR::create_bignum(src);
vector<int> vidx = extract_gmp_R::indice_set_at(result.size(),idx);
vector<int> vidx = extract_gmp_R::indice_get_at(result.size(),idx);
if(vidx.size() == 0) {
return bigrationalR::create_SEXP(result);
......@@ -463,8 +463,8 @@ SEXP bigrational_set_at(SEXP src, SEXP idx, SEXP value)
int pos = 0;
for(int i = 0 ; i < vidx.size(); i++){
while(result.size() <= (vidx[i] )) {
for(unsigned int i = 0 ; i < vidx.size(); i++){
while(result.size() <= (unsigned int ) (vidx[i] )) {
result.push_back(bigrational());
}
result.set(vidx[i],vvalue[pos++ % vvalue.size()]);
......
......@@ -79,74 +79,6 @@ SEXP matrix_set_at_q(SEXP A,SEXP VAL ,SEXP INDI, SEXP INDJ)
}
//
// return a vector of n boolean corresponding to values that must be affected.
//
std::vector<int> extract_gmp_R::indice_set_at (unsigned int n , SEXP & IND)
{
/* if(TYPEOF(IND) == NILSXP){
std::vector<int> result;
return result;
}*/
return indice_get_at(n,IND);
}
/*
std::vector<int> vidx = bigintegerR::create_int(IND);
std::vector<bool> result (n,false);
if(TYPEOF(IND) == NILSXP){
//LOCICAL: return true
for (std::vector<bool>::iterator it = result.begin(); it != result.end(); ++it)
*it = true;
}
else if (TYPEOF(IND) == LGLSXP)
{
for(unsigned int i = 0; i< n; ++i)
result[i] = static_cast<bool>( vidx[i % vidx.size() ] );
}
else
//INTEGERS
{
vidx.erase(std::remove(vidx.begin(), vidx.end(), 0L), vidx.end()); // remove all zeroes
if(vidx.size() == 0){
return result;
}
//negatives integers: all except indices will be modified
if (vidx[0] < 0)
{
for (std::vector<bool>::iterator it = result.begin(); it != result.end(); ++it)
*it = true;
for (std::vector<int>::const_iterator jt = vidx.begin(); jt != vidx.end(); ++jt)
{
if(*jt > 0)
error(_("only 0's may mix with negative subscripts"));
if( (*jt != 0) && (*jt >= - static_cast<int>(n)))
result[-(*jt)-1] = false;
}
}
else
{
//INTEGERS (and positive)
for (std::vector<int>::const_iterator jt = vidx.begin(); jt != vidx.end(); ++jt)
{
if(*jt < 0)
error(_("only 0's may mix with negative subscripts"));
if((*jt != 0) && (*jt <= static_cast<int>(n)))
result[*jt-1] = true;
}
}
}
return(result);
}//end of indice_set_at
*/
//
// return a vector of integers corresponding to values that must be affected.
......@@ -158,10 +90,10 @@ std::vector<int> extract_gmp_R::indice_get_at (unsigned int n , SEXP & IND)
std::vector<int> vidx = bigintegerR::create_int(IND);
std::vector<int> result;
if(TYPEOF(IND) == NILSXP){
//LOCICAL: return true
for (int i = 0; i< n ; i++){
for (unsigned int i = 0; i< n ; i++){
result.push_back(i);
}
}
......
......@@ -56,8 +56,6 @@ namespace extract_gmp_R
* \return a vector of n boolean corresponding to values that must be affected.
*
*/
std::vector<int> indice_set_at (unsigned int n , SEXP & IND);
std::vector<int> indice_get_at (unsigned int n , SEXP & IND);
......@@ -419,17 +417,20 @@ namespace extract_gmp_R
Rf_error("malformed matrix");
unsigned int ncol = src.size() / src.nrow; // number of col
std::vector<int> vidx = indice_set_at ( src.nrow, IDX);
std::vector<int> vjdx = indice_set_at ( ncol, JDX);
std::vector<int> vidx = indice_get_at ( src.nrow, IDX);
std::vector<int> vjdx = indice_get_at ( ncol, JDX);
unsigned int k=0;
for(unsigned int j = 0 ; j < vjdx.size() ; ++j)
{
for(int i = 0 ; i < vidx.size(); ++i)
for(unsigned int i = 0 ; i < vidx.size(); ++i)
{
src.set(vidx[i] + vjdx[j] * src.nrow, value[k % value.size()] );
unsigned int index = vidx[i] + vjdx[j] * src.nrow;
if(index >= src.size()) Rf_error("indice out of bounds");
src.set(index, value[k % value.size()] );
++k;
}
}
......
......@@ -5,7 +5,7 @@
* \version 1
*
* \date Created: 19/02/06
* \date Last modified: Time-stamp: <2022-02-21 16:01:02 (antoine)>
* \date Last modified: Time-stamp: <2022-08-04 15:52:15 (antoine)>
*
* \author A. Lucas
*
......@@ -480,15 +480,12 @@ namespace matrixz
{
bigvec bigint_transpose ( bigvec & mat)
{
int i,j;
bigvec matbis (mat.size());
matbis.nrow = mat.nCols();
/* we compute transpose */
for(i =0; i<mat.nRows(); i++)
for(j =0; j<mat.nCols(); j++)
for(unsigned int i =0; i<mat.nRows(); i++)
for(unsigned int j =0; j<mat.nCols(); j++)
matbis.set(j+i*mat.nCols(),mat[i+j*mat.nRows()]);
return matbis;
......
......@@ -5,7 +5,7 @@
* \version 1
*
* \date Created: 19/02/06
* \date Last modified: Time-stamp: <2022-02-21 15:42:57 (antoine)>
* \date Last modified: Time-stamp: <2022-08-04 15:52:51 (antoine)>
*
* \author A. Lucas
*
......@@ -418,13 +418,11 @@ SEXP bigrational_rbind(SEXP args)
bigvec_q matrixq::bigq_transpose (const bigvec_q & mat)
{
int i,j;
bigvec_q matbis ( mat.size());
matbis.nrow = mat.nCols();
/* we compute transpose */
for(i=0; i < mat.nRows(); i++)
for(j=0; j < mat.nCols(); j++)
for(unsigned int i=0; i < mat.nRows(); i++)
for(unsigned int j=0; j < mat.nCols(); j++)
matbis.value[j+i*mat.nCols()].setValue(mat.value[i+j*mat.nRows()]);
return(matbis);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment