Changeset eea50a in git


Ignore:
Timestamp:
Jun 20, 2012, 12:28:22 PM (11 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'ad2543eab51733612ba7d118afc77edca719600e')
Children:
afda228e98d9cb285f30c2bb20125b83462b7ecd
Parents:
91c8a9344b090c87f8af8b4f8f02bfca00510479
Message:
fix: bigintmat-transpose
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libpolys/coeffs/bigintmat.cc

    r91c8a9 reea50a  
    2424    for (int j=1; j<=col; j++)
    2525    {
    26       t->set(j, i, v[(i-1)*col+(j-1)]);
     26      t->set(j, i, BIMATELEM(*this,i,j));
    2727    }
    2828  }
     
    115115{
    116116  if (a->cols() != b->cols()) return NULL;
     117  if (a->rows() != b->rows()) return NULL;
    117118  if (a->basecoeffs() != b->basecoeffs()) { return NULL; }
    118119
    119   const int mn = si_min(a->rows(),b->rows());
    120   const int ma = si_max(a->rows(),b->rows());
    121 
    122120  const coeffs basecoeffs = a->basecoeffs();
    123121
    124122  int i;
    125123
    126   if (a->cols() == 1)
    127   {
    128     bigintmat * bim = new bigintmat(ma, 1, basecoeffs);
    129 
    130     for (i=0; i<mn; i++)
    131       bim->rawset(i, n_Add((*a)[i], (*b)[i], basecoeffs), basecoeffs);
    132 
    133     if (ma > mn)
    134     {
    135       if (ma == a->rows())
    136         for(i=mn; i<ma; i++)
    137           bim->set(i, (*a)[i], basecoeffs);
    138       else
    139         for(i=mn; i<ma; i++)
    140           bim->set(i, (*b)[i], basecoeffs);
    141     }
    142     return bim;
    143   }
    144 
    145   if (mn != ma) return NULL;
    146 
    147   bigintmat * bim = new bigintmat(mn, a->cols(), basecoeffs);
    148 
    149   for (i=0; i<mn*a->cols(); i++)
     124  bigintmat * bim = new bigintmat(a->rows(), a->cols(), basecoeffs);
     125
     126  for (i=a->rows()*a->cols()-1;i>=0; i--)
    150127    bim->rawset(i, n_Add((*a)[i], (*b)[i], basecoeffs), basecoeffs);
    151128
     
    174151{
    175152  if (a->cols() != b->cols()) return NULL;
     153  if (a->rows() != b->rows()) return NULL;
    176154  if (a->basecoeffs() != b->basecoeffs()) { return NULL; }
    177155
    178   const int mn = si_min(a->rows(),b->rows());
    179   const int ma = si_max(a->rows(),b->rows());
    180 
    181156  const coeffs basecoeffs = a->basecoeffs();
    182157
    183158  int i;
    184159
    185   if (a->cols() == 1)
    186   {
    187     bigintmat * bim = new bigintmat(ma, 1, basecoeffs);
    188 
    189     for (i=0; i<mn; i++)
    190       bim->rawset(i, n_Sub((*a)[i], (*b)[i], basecoeffs), basecoeffs);
    191 
    192     if (ma > mn)
    193     {
    194       if (ma == a->rows())
    195       {
    196         for(i=mn; i<ma; i++)
    197           bim->set(i, (*a)[i], basecoeffs);
    198       }
    199       else
    200         for(i=mn; i<ma; i++)
    201         {
    202           number n = b->get(i);
    203           n = n_Neg(n, basecoeffs);
    204           bim->rawset(i, n, basecoeffs);
    205         }
    206     }
    207     return bim;
    208   }
    209 
    210   if (mn != ma) return NULL;
    211 
    212   bigintmat * bim = new bigintmat(mn, a->cols(), basecoeffs);
    213 
    214   for (i=0; i<mn*a->cols(); i++)
     160  bigintmat * bim = new bigintmat(a->rows(), a->cols(), basecoeffs);
     161
     162  for (i=a->rows()*a->cols()-1;i>=0; i--)
    215163    bim->rawset(i, n_Sub((*a)[i], (*b)[i], basecoeffs), basecoeffs);
    216164
Note: See TracChangeset for help on using the changeset viewer.