Changeset 1099 in Sophya for trunk/SophyaLib/TArray/tarray.cc
- Timestamp:
- Jul 26, 2000, 6:29:46 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/TArray/tarray.cc
r1085 r1099 223 223 void TArray<T>::ReSize(uint_4 ndim, uint_4 * siz, uint_4 step) 224 224 { 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 } 225 231 string exmsg = "TArray<T>::ReSize()"; 226 232 if (!UpdateSizes(ndim, siz, step, 0, exmsg)) throw( ParmError(exmsg) ); … … 239 245 void TArray<T>::Realloc(uint_4 ndim, uint_4 * siz, uint_4 step, bool force) 240 246 { 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 } 241 253 string exmsg = "TArray<T>::Realloc()"; 242 254 if (!UpdateSizes(ndim, siz, step, 0, exmsg)) throw( ParmError(exmsg) ); … … 545 557 if (NbDimensions() < 1) 546 558 throw RangeCheckError("TArray<T>::AddElt(const TArray<T>& ) - Not Allocated Array ! "); 547 if (!CompareSizes(a)) 559 bool smo; 560 if (!CompareSizes(a, smo)) 548 561 throw(SzMismatchError("TArray<T>::AddElt(const TArray<T>&) SizeMismatch")) ; 549 562 … … 551 564 const T * pea; 552 565 uint_8 j,k,ka; 553 if ( (AvgStep() > 0) && (a.AvgStep() > 0)) { // regularly spaced elements566 if (smo && (AvgStep() > 0) && (a.AvgStep() > 0)) { // regularly spaced elements 554 567 uint_8 step = AvgStep(); 555 568 uint_8 stepa = a.AvgStep(); … … 560 573 } 561 574 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); 567 579 for(j=0; j<naxa; j++) { 568 580 pe = mNDBlock.Begin()+Offset(ax,j); 569 pea = a.DataBlock().Begin()+a.Offset(ax ,j);581 pea = a.DataBlock().Begin()+a.Offset(axa,j); 570 582 for(k=0, ka=0; k<gpas; k+=step, ka+=stepa) pe[k] += pea[ka]; 571 583 } … … 584 596 if (NbDimensions() < 1) 585 597 throw RangeCheckError("TArray<T>::SubElt(const TArray<T>& ) - Not Allocated Array ! "); 586 if (!CompareSizes(a)) 598 bool smo; 599 if (!CompareSizes(a, smo)) 587 600 throw(SzMismatchError("TArray<T>::SubElt(const TArray<T>&) SizeMismatch")) ; 588 601 … … 590 603 const T * pea; 591 604 uint_8 j,k,ka; 592 if ( (AvgStep() > 0) && (a.AvgStep() > 0) ) { // regularly spaced elements605 if (smo && (AvgStep() > 0) && (a.AvgStep() > 0) ) { // regularly spaced elements 593 606 uint_8 step = AvgStep(); 594 607 uint_8 stepa = a.AvgStep(); … … 602 615 } 603 616 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); 609 621 for(j=0; j<naxa; j++) { 610 622 pe = mNDBlock.Begin()+Offset(ax,j); 611 pea = a.DataBlock().Begin()+a.Offset(ax ,j);623 pea = a.DataBlock().Begin()+a.Offset(axa,j); 612 624 if (fginv) 613 625 for(k=0, ka=0; k<gpas; k+=step, ka+=stepa) pe[k] = pea[ka]-pe[k] ; … … 626 638 if (NbDimensions() < 1) 627 639 throw RangeCheckError("TArray<T>::MulElt(const TArray<T>& ) - Not Allocated Array ! "); 628 if (!CompareSizes(a)) 640 bool smo; 641 if (!CompareSizes(a, smo)) 629 642 throw(SzMismatchError("TArray<T>::MulElt(const TArray<T>&) SizeMismatch")) ; 630 643 … … 632 645 const T * pea; 633 646 uint_8 j,k,ka; 634 if ( (AvgStep() > 0) && (a.AvgStep() > 0) ) { // regularly spaced elements647 if (smo && (AvgStep() > 0) && (a.AvgStep() > 0) ) { // regularly spaced elements 635 648 uint_8 step = AvgStep(); 636 649 uint_8 stepa = a.AvgStep(); … … 641 654 } 642 655 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); 651 663 for(k=0, ka=0; k<gpas; k+=step, ka+=stepa) pe[k] *= pea[ka]; 652 664 } … … 667 679 if (NbDimensions() < 1) 668 680 throw RangeCheckError("TArray<T>::DivElt(const TArray<T>& ) - Not Allocated Array ! "); 669 if (!CompareSizes(a)) 681 bool smo; 682 if (!CompareSizes(a, smo)) 670 683 throw(SzMismatchError("TArray<T>::DivElt(const TArray<T>&) SizeMismatch")) ; 671 684 … … 673 686 const T * pea; 674 687 uint_8 j,k,ka; 675 if ( (AvgStep() > 0) && (a.AvgStep() > 0) ) { // regularly spaced elements688 if (smo && (AvgStep() > 0) && (a.AvgStep() > 0) ) { // regularly spaced elements 676 689 uint_8 step = AvgStep(); 677 690 uint_8 stepa = a.AvgStep(); … … 694 707 } 695 708 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); 701 713 for(j=0; j<naxa; j++) { 702 714 pe = mNDBlock.Begin()+Offset(ax,j); 703 pea = a.DataBlock().Begin()+a.Offset(ax ,j);715 pea = a.DataBlock().Begin()+a.Offset(axa,j); 704 716 if(divzero) { 705 717 if (fginv) … … 726 738 if (NbDimensions() < 1) 727 739 throw RangeCheckError("TArray<T>::CopyElt(const TArray<T>& ) - Not Allocated Array ! "); 728 if (!CompareSizes(a)) 740 bool smo; 741 if (!CompareSizes(a, smo)) 729 742 throw(SzMismatchError("TArray<T>::CopyElt(const TArray<T>&) SizeMismatch")) ; 730 743 … … 732 745 const T * pea; 733 746 uint_8 j,k,ka; 734 if ( (AvgStep() > 0) && (a.AvgStep() > 0) ) { // regularly spaced elements747 if (smo && (AvgStep() > 0) && (a.AvgStep() > 0) ) { // regularly spaced elements 735 748 uint_8 step = AvgStep(); 736 749 uint_8 stepa = a.AvgStep(); … … 741 754 } 742 755 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); 748 760 for(j=0; j<naxa; j++) { 749 761 pe = mNDBlock.Begin()+Offset(ax,j); 750 pea = a.DataBlock().Begin()+a.Offset(ax ,j);762 pea = a.DataBlock().Begin()+a.Offset(axa,j); 751 763 for(k=0, ka=0; k<gpas; k+=step, ka+=stepa) pe[k] = pea[ka]; 752 764 } … … 761 773 if (NbDimensions() < 1) 762 774 throw RangeCheckError("TArray<T>::ConvertAndCopyElt(const TArray<T>& ) - Not Allocated Array ! "); 763 if (!CompareSizes(a)) 775 bool smo; 776 if (!CompareSizes(a, smo)) 764 777 throw(SzMismatchError("TArray<T>::ConvertAndCopyElt(const TArray<T>&) SizeMismatch")) ; 765 778 … … 768 781 uint_8 offa; 769 782 // 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); 775 787 for(j=0; j<naxa; j++) { 776 788 pe = mNDBlock.Begin()+Offset(ax,j); 777 offa = a.Offset(ax ,j);789 offa = a.Offset(axa,j); 778 790 #if !defined(__GNUG__) 779 791 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.