Changeset 1099 in Sophya for trunk/SophyaLib/TArray/tarray.cc


Ignore:
Timestamp:
Jul 26, 2000, 6:29:46 PM (25 years ago)
Author:
ansari
Message:

Protection integrite TMatrix,TVector - operateur = (BaseArray & pour TVector et operations entre matrices avec <> MemMapping (Pas termine) Reza 27/6/2000

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaLib/TArray/tarray.cc

    r1085 r1099  
    223223void TArray<T>::ReSize(uint_4 ndim, uint_4 * siz, uint_4 step)
    224224{
     225  if (arrtype_ != 0) {
     226    if (ndim != 2)
     227       throw( ParmError("TArray<T>::ReSize(ndim!=2,...) for Matrix" ) );
     228    if ((arrtype_ == 2) && (siz[0] > 1) && (siz[1] > 1))
     229       throw( ParmError("TArray<T>::ReSize(,siz[0]>1 && size[1]>1) for Vector" ) );
     230  }
    225231  string exmsg = "TArray<T>::ReSize()";
    226232  if (!UpdateSizes(ndim, siz, step, 0, exmsg))  throw( ParmError(exmsg) );
     
    239245void TArray<T>::Realloc(uint_4 ndim, uint_4 * siz, uint_4 step, bool force)
    240246{
     247  if (arrtype_ != 0) {
     248    if (ndim != 2)
     249       throw( ParmError("TArray<T>::Realloc(ndim!=2,...) for Matrix" ) );
     250    if ((arrtype_ == 2) && (siz[0] > 1) && (siz[1] > 1))
     251       throw( ParmError("TArray<T>::Realloc(,siz[0]>1 && size[1]>1) for Vector" ) );
     252  }
    241253  string exmsg = "TArray<T>::Realloc()";
    242254  if (!UpdateSizes(ndim, siz, step, 0, exmsg))  throw( ParmError(exmsg) );
     
    545557  if (NbDimensions() < 1)
    546558    throw RangeCheckError("TArray<T>::AddElt(const TArray<T>& )  - Not Allocated Array ! ");
    547   if (!CompareSizes(a))
     559  bool smo;
     560  if (!CompareSizes(a, smo))
    548561    throw(SzMismatchError("TArray<T>::AddElt(const TArray<T>&) SizeMismatch")) ;
    549562
     
    551564  const T * pea;
    552565  uint_8 j,k,ka;
    553   if ((AvgStep() > 0) && (a.AvgStep() > 0) )   {  // regularly spaced elements
     566  if (smo && (AvgStep() > 0) && (a.AvgStep() > 0))   {  // regularly spaced elements
    554567    uint_8 step = AvgStep();
    555568    uint_8 stepa = a.AvgStep();
     
    560573  }
    561574  else {    // Non regular data spacing ...
    562     uint_4 ax = MaxSizeKA();
    563     uint_8 step = Step(ax);
    564     uint_8 stepa = a.Step(ax);
    565     uint_8 gpas = Size(ax)*step;
    566     uint_8 naxa = Size()/Size(ax);
     575    int ax,axa;
     576    uint_8 step, stepa;
     577    uint_8 gpas, naxa;
     578    GetOpeParams(a, smo, ax, axa, step, stepa, gpas, naxa);
    567579    for(j=0; j<naxa; j++)  {
    568580      pe = mNDBlock.Begin()+Offset(ax,j);
    569       pea = a.DataBlock().Begin()+a.Offset(ax,j);
     581      pea = a.DataBlock().Begin()+a.Offset(axa,j);
    570582      for(k=0, ka=0;  k<gpas;  k+=step, ka+=stepa)  pe[k] += pea[ka];
    571583    }
     
    584596  if (NbDimensions() < 1)
    585597    throw RangeCheckError("TArray<T>::SubElt(const TArray<T>& )  - Not Allocated Array ! ");
    586   if (!CompareSizes(a))
     598  bool smo;
     599  if (!CompareSizes(a, smo))
    587600    throw(SzMismatchError("TArray<T>::SubElt(const TArray<T>&) SizeMismatch")) ;
    588601
     
    590603  const T * pea;
    591604  uint_8 j,k,ka;
    592   if ((AvgStep() > 0) && (a.AvgStep() > 0) )   {  // regularly spaced elements
     605  if (smo && (AvgStep() > 0) && (a.AvgStep() > 0) )   {  // regularly spaced elements
    593606    uint_8 step = AvgStep();
    594607    uint_8 stepa = a.AvgStep();
     
    602615  }
    603616  else {    // Non regular data spacing ...
    604     uint_4 ax = MaxSizeKA();
    605     uint_8 step = Step(ax);
    606     uint_8 stepa = a.Step(ax);
    607     uint_8 gpas = Size(ax)*step;
    608     uint_8 naxa = Size()/Size(ax);
     617    int ax,axa;
     618    uint_8 step, stepa;
     619    uint_8 gpas, naxa;
     620    GetOpeParams(a, smo, ax, axa, step, stepa, gpas, naxa);
    609621    for(j=0; j<naxa; j++)  {
    610622      pe = mNDBlock.Begin()+Offset(ax,j);
    611       pea = a.DataBlock().Begin()+a.Offset(ax,j);
     623      pea = a.DataBlock().Begin()+a.Offset(axa,j);
    612624      if (fginv)
    613625        for(k=0, ka=0;  k<gpas;  k+=step, ka+=stepa)  pe[k] = pea[ka]-pe[k] ;
     
    626638  if (NbDimensions() < 1)
    627639    throw RangeCheckError("TArray<T>::MulElt(const TArray<T>& )  - Not Allocated Array ! ");
    628   if (!CompareSizes(a))
     640  bool smo;
     641  if (!CompareSizes(a, smo))
    629642    throw(SzMismatchError("TArray<T>::MulElt(const TArray<T>&) SizeMismatch")) ;
    630643
     
    632645  const T * pea;
    633646  uint_8 j,k,ka;
    634   if ((AvgStep() > 0) && (a.AvgStep() > 0) )   {  // regularly spaced elements
     647  if (smo && (AvgStep() > 0) && (a.AvgStep() > 0) )   {  // regularly spaced elements
    635648    uint_8 step = AvgStep();
    636649    uint_8 stepa = a.AvgStep();
     
    641654  }
    642655  else {    // Non regular data spacing ...
    643     uint_4 ax = MaxSizeKA();
    644     uint_8 step = Step(ax);
    645     uint_8 stepa = a.Step(ax);
    646     uint_8 gpas = Size(ax)*step;
    647     uint_8 naxa = Size()/Size(ax);
    648     for(j=0; j<naxa; j++)  {
    649       pe = mNDBlock.Begin()+Offset(ax,j);
    650       pea = a.DataBlock().Begin()+a.Offset(ax,j);
     656    int ax,axa;
     657    uint_8 step, stepa;
     658    uint_8 gpas, naxa;
     659    GetOpeParams(a, smo, ax, axa, step, stepa, gpas, naxa);
     660    for(j=0; j<naxa; j++)  {
     661      pe = mNDBlock.Begin()+Offset(axa,j);
     662      pea = a.DataBlock().Begin()+a.Offset(axa,j);
    651663      for(k=0, ka=0;  k<gpas;  k+=step, ka+=stepa)  pe[k] *= pea[ka];
    652664    }
     
    667679  if (NbDimensions() < 1)
    668680    throw RangeCheckError("TArray<T>::DivElt(const TArray<T>& )  - Not Allocated Array ! ");
    669   if (!CompareSizes(a))
     681  bool smo;
     682  if (!CompareSizes(a, smo))
    670683    throw(SzMismatchError("TArray<T>::DivElt(const TArray<T>&) SizeMismatch")) ;
    671684
     
    673686  const T * pea;
    674687  uint_8 j,k,ka;
    675   if ((AvgStep() > 0) && (a.AvgStep() > 0) )   {  // regularly spaced elements
     688  if (smo && (AvgStep() > 0) && (a.AvgStep() > 0) )   {  // regularly spaced elements
    676689    uint_8 step = AvgStep();
    677690    uint_8 stepa = a.AvgStep();
     
    694707  }
    695708  else {    // Non regular data spacing ...
    696     uint_4 ax = MaxSizeKA();
    697     uint_8 step = Step(ax);
    698     uint_8 stepa = a.Step(ax);
    699     uint_8 gpas = Size(ax)*step;
    700     uint_8 naxa = Size()/Size(ax);
     709    int ax,axa;
     710    uint_8 step, stepa;
     711    uint_8 gpas, naxa;
     712    GetOpeParams(a, smo, ax, axa, step, stepa, gpas, naxa);
    701713    for(j=0; j<naxa; j++)  {
    702714      pe = mNDBlock.Begin()+Offset(ax,j);
    703       pea = a.DataBlock().Begin()+a.Offset(ax,j);
     715      pea = a.DataBlock().Begin()+a.Offset(axa,j);
    704716      if(divzero) {
    705717        if (fginv)
     
    726738  if (NbDimensions() < 1)
    727739    throw RangeCheckError("TArray<T>::CopyElt(const TArray<T>& )  - Not Allocated Array ! ");
    728   if (!CompareSizes(a))
     740  bool smo;
     741  if (!CompareSizes(a, smo))
    729742    throw(SzMismatchError("TArray<T>::CopyElt(const TArray<T>&) SizeMismatch")) ;
    730743
     
    732745  const T * pea;
    733746  uint_8 j,k,ka;
    734   if ((AvgStep() > 0) && (a.AvgStep() > 0) )   {  // regularly spaced elements
     747  if (smo && (AvgStep() > 0) && (a.AvgStep() > 0) )   {  // regularly spaced elements
    735748    uint_8 step = AvgStep();
    736749    uint_8 stepa = a.AvgStep();
     
    741754  }
    742755  else {    // Non regular data spacing ...
    743     uint_4 ax = MaxSizeKA();
    744     uint_8 step = Step(ax);
    745     uint_8 stepa = a.Step(ax);
    746     uint_8 gpas = Size(ax)*step;
    747     uint_8 naxa = Size()/Size(ax);
     756    int ax,axa;
     757    uint_8 step, stepa;
     758    uint_8 gpas, naxa;
     759    GetOpeParams(a, smo, ax, axa, step, stepa, gpas, naxa);
    748760    for(j=0; j<naxa; j++)  {
    749761      pe = mNDBlock.Begin()+Offset(ax,j);
    750       pea = a.DataBlock().Begin()+a.Offset(ax,j);
     762      pea = a.DataBlock().Begin()+a.Offset(axa,j);
    751763      for(k=0, ka=0;  k<gpas;  k+=step, ka+=stepa)  pe[k] = pea[ka];
    752764    }
     
    761773  if (NbDimensions() < 1)
    762774    throw RangeCheckError("TArray<T>::ConvertAndCopyElt(const TArray<T>& )  - Not Allocated Array ! ");
    763   if (!CompareSizes(a))
     775  bool smo;
     776  if (!CompareSizes(a, smo))
    764777    throw(SzMismatchError("TArray<T>::ConvertAndCopyElt(const TArray<T>&) SizeMismatch")) ;
    765778
     
    768781  uint_8 offa;
    769782  // Non regular data spacing ...
    770   uint_4 ax = MaxSizeKA();
    771   uint_8 step = Step(ax);
    772   uint_8 stepa = a.Step(ax);
    773   uint_8 gpas = Size(ax)*step;
    774   uint_8 naxa = Size()/Size(ax);
     783  int ax,axa;
     784  uint_8 step, stepa;
     785  uint_8 gpas, naxa;
     786  GetOpeParams(a, smo, ax, axa, step, stepa, gpas, naxa);
    775787  for(j=0; j<naxa; j++)  {
    776788    pe = mNDBlock.Begin()+Offset(ax,j);
    777     offa = a.Offset(ax,j);
     789    offa = a.Offset(axa,j);
    778790#if !defined(__GNUG__)
    779791    for(k=0, ka=0;  k<gpas;  k+=step, ka+=stepa)  pe[k] = (T)a.ValueAtPosition(offa+ka);
Note: See TracChangeset for help on using the changeset viewer.