Commit 57aac7c0 authored by Antoine Lucas's avatar Antoine Lucas
Browse files

correctif rbind + simplification

parent 7319e137
......@@ -5,7 +5,7 @@
* \version 1
*
* \date Created: 19/02/06
* \date Last modified: Time-stamp: <2022-02-21 15:38:21 (antoine)>
* \date Last modified: Time-stamp: <2022-02-21 16:01:02 (antoine)>
*
* \author A. Lucas
*
......@@ -103,8 +103,7 @@ SEXP as_matrixz (SEXP x, SEXP nrR, SEXP ncR, SEXP byrowR, SEXP mod)
mat.nrow = nr;
if(byrow)
{
bigvec mat2 = matrixz::bigint_transpose (mat, nc,nr);
mat2.nrow = nr;// FIXME - needed ??
bigvec mat2 = matrixz::bigint_transpose (mat);
return( bigintegerR::create_SEXP (mat2));
}
......@@ -132,9 +131,10 @@ SEXP bigint_transposeR(SEXP x)
error(_("argument must be a matrix of class \"bigz\""));
}
UNPROTECT(2);
int nc = (int) n / nr;
mat.nrow = nr;
// Rprintf(" o bigI_tr(<%d x %d>) ..\n", nr,nc);
return( bigintegerR::create_SEXP(matrixz::bigint_transpose(mat, nr,nc)));
return( bigintegerR::create_SEXP(matrixz::bigint_transpose(mat)));
}
......@@ -456,26 +456,21 @@ SEXP biginteger_rbind(SEXP args)
if(result.nrow<=0)
result.nrow = result.size();
printf("transpose\n");
result = matrixz::bigint_transpose(result, result.nRows(),
result.size() / result.nRows());
printf("transpose done\n");
result = matrixz::bigint_transpose(result);
for(i=1; i < LENGTH(args); i++)
{
printf("process %d\n",i);
v = bigintegerR::create_bignum(VECTOR_ELT(args,i));
if(v.nrow <= 0 )
v.nrow = v.size();
v = matrixz::bigint_transpose(v,v.nrow,v.size() / v.nRows());
v = matrixz::bigint_transpose(v);
for(j=0; j< (int)v.size(); j++)
result.push_back(v[j]);
v.clear();
printf("process %d done\n",i);
}
result = matrixz::bigint_transpose(result, result.nRows(),
result.size() / result.nRows());
result = matrixz::bigint_transpose(result);
return bigintegerR::create_SEXP(result);
}
......@@ -483,18 +478,18 @@ SEXP biginteger_rbind(SEXP args)
namespace matrixz
{
bigvec bigint_transpose ( bigvec & mat,int nr,int nc)
bigvec bigint_transpose ( bigvec & mat)
{
int i,j;
bigvec matbis (nr * nc);
matbis.nrow = nc;
bigvec matbis (mat.size());
matbis.nrow = mat.nCols();
/* we compute transpose */
for(i =0; i<nr; i++)
for(j =0; j<nc; j++)
matbis.set(j+i*nc,mat[i+j*nr]);
for(i =0; i<mat.nRows(); i++)
for(j =0; j<mat.nCols(); j++)
matbis.set(j+i*mat.nCols(),mat[i+j*mat.nRows()]);
return matbis;
}
......
......@@ -4,7 +4,7 @@
* \version 1
*
* \date Created: 25/05/06
* \date Last modified: Time-stamp: <2006-05-26 14:28:09 antoine>
* \date Last modified: Time-stamp: <2022-02-21 15:57:36 (antoine)>
*
* \author A. Lucas
*
......@@ -52,7 +52,7 @@ extern "C"
namespace matrixz{
/** \brief C function use to transpose a matrix */
bigvec bigint_transpose ( bigvec & mat,int nr,int nc);
bigvec bigint_transpose ( bigvec & mat);
/** \brief Check dimension compatibility */
int checkDims(int dima,int dimb);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment