@@ -464,6 +464,15 @@ class LASymMatrix {
464
464
std::memcpy (fData , v.Data (), fSize * sizeof (double ));
465
465
}
466
466
467
+ LASymMatrix (LASymMatrix &&v)
468
+ : fSize(v.size()),
469
+ fNRow(v.Nrow()),
470
+ fData(v.fData )
471
+ {
472
+ v.fData = nullptr ;
473
+ }
474
+
475
+
467
476
LASymMatrix &operator =(const LASymMatrix &v)
468
477
{
469
478
if (fSize < v.size ()) {
@@ -472,11 +481,22 @@ class LASymMatrix {
472
481
fSize = v.size ();
473
482
fNRow = v.Nrow ();
474
483
fData = (double *)StackAllocatorHolder::Get ().Allocate (sizeof (double ) * fSize );
484
+ } else if (fSize > v.size ()) {
485
+ throw std::runtime_error (" Can't assign smaller LASymMatrix to larger LASymMatrix" );
475
486
}
476
487
std::memcpy (fData , v.Data (), fSize * sizeof (double ));
477
488
return *this ;
478
489
}
479
490
491
+ LASymMatrix &operator =(LASymMatrix &&v)
492
+ {
493
+ fSize = v.size ();
494
+ fNRow = v.Nrow ();
495
+ fData = v.Data ();
496
+ v.fData = nullptr ;
497
+ return *this ;
498
+ }
499
+
480
500
template <class T >
481
501
LASymMatrix (const ABObj<sym, LASymMatrix, T> &v)
482
502
: fSize (v.Obj().size()),
@@ -822,6 +842,12 @@ class LAVector {
822
842
StackAllocatorHolder::Get ().Deallocate (fData );
823
843
}
824
844
845
+ LAVector (LAVector &&v)
846
+ : fSize (v.size()), fData (v.Data())
847
+ {
848
+ fData = nullptr ;
849
+ }
850
+
825
851
LAVector (const LAVector &v) : LAVector{std::span<const double >{v.Data (), v.size ()}} {}
826
852
827
853
explicit LAVector (std::span<const double > v)
@@ -838,11 +864,21 @@ class LAVector {
838
864
StackAllocatorHolder::Get ().Deallocate (fData );
839
865
fSize = v.size ();
840
866
fData = (double *)StackAllocatorHolder::Get ().Allocate (sizeof (double ) * fSize );
867
+ } else if (fSize > v.size ()) {
868
+ throw std::runtime_error (" Can't assign smaller LAVector to larger LAVector" );
841
869
}
842
870
std::memcpy (fData , v.Data (), fSize * sizeof (double ));
843
871
return *this ;
844
872
}
845
873
874
+ LAVector &operator =(LAVector &&v)
875
+ {
876
+ fSize = v.fSize ;
877
+ fData = v.fData ;
878
+ v.fData = nullptr ;
879
+ return *this ;
880
+ }
881
+
846
882
template <class T >
847
883
LAVector (const ABObj<vec, LAVector, T> &v)
848
884
: fSize (v.Obj().size()), fData ((double *)StackAllocatorHolder::Get().Allocate(sizeof (double ) * v.Obj().size()))
0 commit comments