Commit 7319e137 authored by Antoine Lucas's avatar Antoine Lucas
Browse files

bug fix rbind(u,u) with u vector

parent b9e30810
......@@ -5,7 +5,7 @@
* \version 1
*
* \date Created: 19/02/06
* \date Last modified: Time-stamp: <2006-06-17 23:10:44 antoine>
* \date Last modified: Time-stamp: <2022-02-21 15:38:21 (antoine)>
*
* \author A. Lucas
*
......@@ -453,25 +453,29 @@ SEXP biginteger_rbind(SEXP args)
bigvec v;
result = bigintegerR::create_bignum(VECTOR_ELT(args,0));
if(result.nrow==0)
if(result.nrow<=0)
result.nrow = result.size();
result = matrixz::bigint_transpose(result, result.nrow,
result.size() / result.nrow);
printf("transpose\n");
result = matrixz::bigint_transpose(result, result.nRows(),
result.size() / result.nRows());
printf("transpose done\n");
for(i=1; i < LENGTH(args); i++)
{
printf("process %d\n",i);
v = bigintegerR::create_bignum(VECTOR_ELT(args,i));
if(v.nrow == 0 )
if(v.nrow <= 0 )
v.nrow = v.size();
v = matrixz::bigint_transpose(v,v.nrow,v.size() / v.nrow);
v = matrixz::bigint_transpose(v,v.nrow,v.size() / v.nRows());
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.nrow,
result.size() / result.nrow);
result = matrixz::bigint_transpose(result, result.nRows(),
result.size() / result.nRows());
return bigintegerR::create_SEXP(result);
}
......@@ -483,7 +487,7 @@ namespace matrixz
{
int i,j;
/* cas: square matrix */
bigvec matbis (nr * nc);
matbis.nrow = nc;
......
......@@ -5,7 +5,7 @@
* \version 1
*
* \date Created: 19/02/06
* \date Last modified: Time-stamp: <2008-02-17 19:54:11 antoine>
* \date Last modified: Time-stamp: <2022-02-21 15:42:57 (antoine)>
*
* \author A. Lucas
*
......@@ -91,7 +91,7 @@ SEXP as_matrixq (SEXP x, SEXP nrR, SEXP ncR, SEXP byrowR, SEXP den)
mat.nrow = nr;
if(byrow)
{
bigvec_q mat2 = matrixq::bigq_transpose (mat, nc,nr);
bigvec_q mat2 = matrixq::bigq_transpose (mat);
mat2.nrow = nr;
return( bigrationalR::create_SEXP (mat2));
}
......@@ -118,9 +118,9 @@ SEXP bigq_transposeR(SEXP x)
error(_("argument must be a matrix of class \"bigq\""));
nr = -1;// -Wall
}
mat.nrow = nr;
int nc = (int) n / nr;
bigvec_q mat_transp = matrixq::bigq_transpose(mat, nr,nc);
bigvec_q mat_transp = matrixq::bigq_transpose(mat);
mat_transp.nrow = nc; // FIXME - needed ?
UNPROTECT(2);
return( bigrationalR::create_SEXP( mat_transp));
......@@ -396,37 +396,36 @@ SEXP bigrational_rbind(SEXP args)
bigvec_q v;
result = bigrationalR::create_bignum(VECTOR_ELT(args,0));
if(result.nrow ==0)
if(result.nrow <=0)
result.nrow = result.size();
result = matrixq::bigq_transpose(result, result.nrow,
result.size() / result.nrow);
result = matrixq::bigq_transpose(result);
for(i=1; i< LENGTH(args); i++) {
v = bigrationalR::create_bignum(VECTOR_ELT(args,i));
if(v.nrow == 0 )
v.nrow = v.size();
v = matrixq::bigq_transpose(v,v.nrow,v.size() / v.nrow);
v = matrixq::bigq_transpose(v);
for(j=0; j< (int)v.size(); j++)
result.push_back(v[j]);
v.clear();
}
result = matrixq::bigq_transpose(result, result.nrow,
result.size() / result.nrow);
result = matrixq::bigq_transpose(result);
return bigrationalR::create_SEXP(result);
}
bigvec_q matrixq::bigq_transpose (const bigvec_q & mat,int nr,int nc)
bigvec_q matrixq::bigq_transpose (const bigvec_q & mat)
{
int i,j;
bigvec_q matbis (nr * nc);
matbis.nrow = nc;
bigvec_q matbis ( mat.size());
matbis.nrow = mat.nCols();
/* we compute transpose */
for(i=0; i < nr; i++)
for(j=0; j < nc; j++)
matbis.value[j+i*nc].setValue(mat.value[i+j*nr]);
for(i=0; i < mat.nRows(); i++)
for(j=0; j < mat.nCols(); j++)
matbis.value[j+i*mat.nCols()].setValue(mat.value[i+j*mat.nRows()]);
return(matbis);
}
......@@ -2,7 +2,7 @@
* \brief header for rational matrix functions set
*
* \date Created: 2005
* \date Last modified: Time-stamp: <2006-05-26 14:35:51 antoine>
* \date Last modified: Time-stamp: <2022-02-21 15:43:22 (antoine)>
*
*
* \note Licence: GPL (>= 2)
......@@ -41,7 +41,7 @@ namespace matrixq
/**
* \brief C++ function use to transpose matrix
*/
bigvec_q bigq_transpose (const bigvec_q & mat,int nr,int nc);
bigvec_q bigq_transpose (const bigvec_q & mat);
}
......@@ -65,15 +65,14 @@ namespace math{
set(i , k, get(i,k) * lambda );
}
Matrix & transpose();
Matrix * transpose();
};
template< class T>
class Transpose: public Matrix<T> {
private :
Matrix<T> & source;
public:
Transpose(Matrix<T> & source_p)
: source(source_p) {
......@@ -83,6 +82,10 @@ namespace math{
return source.size();
}
bool isVector() const {
return false;
}
unsigned int nRows() const {
return source.nCols();
}
......@@ -110,11 +113,11 @@ namespace math{
}
template<class T>
Matrix<T> & Matrix<T>::transpose(){
Matrix<T> * Matrix<T>::transpose(){
if (transposate == 0){
transposate =new Transpose<T>(*this);
}
return *transposate;
return transposate;
}
template<class T>
......
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