Skip to content

Commit f89b604

Browse files
committed
Merge branch 'master' of https://github.com/sofa-framework/sofa
2 parents 24003f3 + 9b5f80e commit f89b604

File tree

4 files changed

+188
-55
lines changed

4 files changed

+188
-55
lines changed

Sofa/framework/Core/src/sofa/core/objectmodel/DataLink.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class SOFA_CORE_API DataLink final : public AbstractDataLink
3939
public:
4040

4141
DataLink(T& owner) : m_owner{owner} { }
42-
virtual ~DataLink() {}
42+
~DataLink() = default;
4343

4444
T* getTarget() const
4545
{

Sofa/framework/LinearAlgebra/src/sofa/linearalgebra/CompressedRowSparseMatrixMechanical.h

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -446,28 +446,28 @@ class CompressedRowSparseMatrixMechanical final // final is used to allow the co
446446
/// @{
447447

448448
/// @return type of elements stored in this matrix
449-
virtual ElementType getElementType() const override { return traits::getElementType(); }
449+
ElementType getElementType() const override { return traits::getElementType(); }
450450

451451
/// @return size of elements stored in this matrix
452-
virtual std::size_t getElementSize() const override { return sizeof(Real); }
452+
std::size_t getElementSize() const override { return sizeof(Real); }
453453

454454
/// @return the category of this matrix
455-
virtual MatrixCategory getCategory() const override { return MATRIX_SPARSE; }
455+
MatrixCategory getCategory() const override { return MATRIX_SPARSE; }
456456

457457
/// @return the number of rows in each block, or 1 of there are no fixed block size
458-
virtual Index getBlockRows() const override { return NL; }
458+
Index getBlockRows() const override { return NL; }
459459

460460
/// @return the number of columns in each block, or 1 of there are no fixed block size
461-
virtual Index getBlockCols() const override { return NC; }
461+
Index getBlockCols() const override { return NC; }
462462

463463
/// @return the number of rows of blocks
464-
virtual Index bRowSize() const override{ return this->rowBSize(); }
464+
Index bRowSize() const override{ return this->rowBSize(); }
465465

466466
/// @return the number of columns of blocks
467-
virtual Index bColSize() const override { return this->colBSize(); }
467+
Index bColSize() const override { return this->colBSize(); }
468468

469469
/// @return the width of the band on each side of the diagonal (only for band matrices)
470-
virtual Index getBandWidth() const override { return NC-1; }
470+
Index getBandWidth() const override { return NC-1; }
471471

472472
/// @}
473473

@@ -641,23 +641,23 @@ class CompressedRowSparseMatrixMechanical final // final is used to allow the co
641641
/// @{
642642

643643
protected:
644-
virtual void bAccessorDelete(const InternalBlockAccessor* /*b*/) const override {}
645-
virtual void bAccessorCopy(InternalBlockAccessor* /*b*/) const override {}
646-
virtual SReal bAccessorElement(const InternalBlockAccessor* b, Index i, Index j) const override
644+
void bAccessorDelete(const InternalBlockAccessor* /*b*/) const override {}
645+
void bAccessorCopy(InternalBlockAccessor* /*b*/) const override {}
646+
SReal bAccessorElement(const InternalBlockAccessor* b, Index i, Index j) const override
647647
{
648648
//return element(b->row * getBlockRows() + i, b->col * getBlockCols() + j);
649649
Index index = b->data;
650650
const Block& data = (index >= 0) ? this->colsValue[index] : this->btemp[-index-1].value;
651651
return static_cast<SReal>(traits::v(data, i, j));
652652
}
653-
virtual void bAccessorSet(InternalBlockAccessor* b, Index i, Index j, double v) override
653+
void bAccessorSet(InternalBlockAccessor* b, Index i, Index j, double v) override
654654
{
655655
//set(b->row * getBlockRows() + i, b->col * getBlockCols() + j, v);
656656
Index index = b->data;
657657
Block& data = (index >= 0) ? this->colsValue[index] : this->btemp[-index-1].value;
658658
traits::vset(data, i, j, static_cast<Real>(v) );
659659
}
660-
virtual void bAccessorAdd(InternalBlockAccessor* b, Index i, Index j, double v) override
660+
void bAccessorAdd(InternalBlockAccessor* b, Index i, Index j, double v) override
661661
{
662662
//add(b->row * getBlockRows() + i, b->col * getBlockCols() + j, v);
663663
Index index = b->data;
@@ -675,15 +675,15 @@ class CompressedRowSparseMatrixMechanical final // final is used to allow the co
675675
buffer[l*NC+c] = static_cast<T>(traits::v(data, l, c));
676676
return buffer;
677677
}
678-
virtual const float* bAccessorElements(const InternalBlockAccessor* b, float* buffer) const override
678+
const float* bAccessorElements(const InternalBlockAccessor* b, float* buffer) const override
679679
{
680680
return bAccessorElementsCSRImpl<float>(b, buffer);
681681
}
682-
virtual const double* bAccessorElements(const InternalBlockAccessor* b, double* buffer) const override
682+
const double* bAccessorElements(const InternalBlockAccessor* b, double* buffer) const override
683683
{
684684
return bAccessorElementsCSRImpl<double>(b, buffer);
685685
}
686-
virtual const int* bAccessorElements(const InternalBlockAccessor* b, int* buffer) const override
686+
const int* bAccessorElements(const InternalBlockAccessor* b, int* buffer) const override
687687
{
688688
return bAccessorElementsCSRImpl<int>(b, buffer);
689689
}
@@ -697,15 +697,15 @@ class CompressedRowSparseMatrixMechanical final // final is used to allow the co
697697
for (Index c=0; c < (Index)NC; ++c)
698698
traits::vset(data, l, c, static_cast<Real>(buffer[l*NC+c]) );
699699
}
700-
virtual void bAccessorSet(InternalBlockAccessor* b, const float* buffer) override
700+
void bAccessorSet(InternalBlockAccessor* b, const float* buffer) override
701701
{
702702
bAccessorSetCSRImpl<float>(b, buffer);
703703
}
704-
virtual void bAccessorSet(InternalBlockAccessor* b, const double* buffer) override
704+
void bAccessorSet(InternalBlockAccessor* b, const double* buffer) override
705705
{
706706
bAccessorSetCSRImpl<double>(b, buffer);
707707
}
708-
virtual void bAccessorSet(InternalBlockAccessor* b, const int* buffer) override
708+
void bAccessorSet(InternalBlockAccessor* b, const int* buffer) override
709709
{
710710
bAccessorSetCSRImpl<int>(b, buffer);
711711
}
@@ -719,23 +719,23 @@ class CompressedRowSparseMatrixMechanical final // final is used to allow the co
719719
for (Index c=0; c < (Index)NC; ++c)
720720
traits::vadd(data, l, c,static_cast<Real>(buffer[l*NC+c]) );
721721
}
722-
virtual void bAccessorAdd(InternalBlockAccessor* b, const float* buffer) override
722+
void bAccessorAdd(InternalBlockAccessor* b, const float* buffer) override
723723
{
724724
bAccessorAddCSRImpl<float>(b, buffer);
725725
}
726-
virtual void bAccessorAdd(InternalBlockAccessor* b, const double* buffer) override
726+
void bAccessorAdd(InternalBlockAccessor* b, const double* buffer) override
727727
{
728728
bAccessorAddCSRImpl<double>(b, buffer);
729729
}
730-
virtual void bAccessorAdd(InternalBlockAccessor* b, const int* buffer) override
730+
void bAccessorAdd(InternalBlockAccessor* b, const int* buffer) override
731731
{
732732
bAccessorAddCSRImpl<int>(b, buffer);
733733
}
734734

735735
public:
736736

737737
/// Get read access to a block
738-
virtual BlockConstAccessor blockGet(Index i, Index j) const
738+
BlockConstAccessor blockGet(Index i, Index j) const
739739
{
740740
if constexpr (Policy::AutoCompress) const_cast<Matrix*>(this)->compress(); /// \warning this violates the const-ness of the method !
741741

@@ -753,7 +753,7 @@ class CompressedRowSparseMatrixMechanical final // final is used to allow the co
753753
}
754754

755755
/// Get write access to a block
756-
virtual BlockAccessor blockGetW(Index i, Index j)
756+
BlockAccessor blockGetW(Index i, Index j)
757757
{
758758
if constexpr (Policy::AutoCompress) compress();
759759

@@ -771,7 +771,7 @@ class CompressedRowSparseMatrixMechanical final // final is used to allow the co
771771
}
772772

773773
/// Get write access to a block, possibly creating it
774-
virtual BlockAccessor blockCreate(Index i, Index j)
774+
BlockAccessor blockCreate(Index i, Index j)
775775
{
776776
Index rowId = Index(i * this->rowIndex.size() / this->nBlockRow);
777777
if (this->sortedFind(this->rowIndex, i, rowId))
@@ -792,35 +792,35 @@ class CompressedRowSparseMatrixMechanical final // final is used to allow the co
792792
}
793793

794794
protected:
795-
virtual void itCopyColBlock(InternalColBlockIterator* /*it*/) const override {}
796-
virtual void itDeleteColBlock(const InternalColBlockIterator* /*it*/) const override {}
797-
virtual void itAccessColBlock(InternalColBlockIterator* it, BlockConstAccessor* b) const override
795+
void itCopyColBlock(InternalColBlockIterator* /*it*/) const override {}
796+
void itDeleteColBlock(const InternalColBlockIterator* /*it*/) const override {}
797+
void itAccessColBlock(InternalColBlockIterator* it, BlockConstAccessor* b) const override
798798
{
799799
Index index = it->data;
800800
setMatrix(b);
801801
getInternal(b)->row = it->row;
802802
getInternal(b)->data = index;
803803
getInternal(b)->col = this->colsIndex[index];
804804
}
805-
virtual void itIncColBlock(InternalColBlockIterator* it) const override
805+
void itIncColBlock(InternalColBlockIterator* it) const override
806806
{
807807
Index index = it->data;
808808
++index;
809809
it->data = index;
810810
}
811-
virtual void itDecColBlock(InternalColBlockIterator* it) const override
811+
void itDecColBlock(InternalColBlockIterator* it) const override
812812
{
813813
Index index = it->data;
814814
--index;
815815
it->data = index;
816816
}
817-
virtual bool itEqColBlock(const InternalColBlockIterator* it, const InternalColBlockIterator* it2) const override
817+
bool itEqColBlock(const InternalColBlockIterator* it, const InternalColBlockIterator* it2) const override
818818
{
819819
Index index = it->data;
820820
Index index2 = it2->data;
821821
return index == index2;
822822
}
823-
virtual bool itLessColBlock(const InternalColBlockIterator* it, const InternalColBlockIterator* it2) const override
823+
bool itLessColBlock(const InternalColBlockIterator* it, const InternalColBlockIterator* it2) const override
824824
{
825825
Index index = it->data;
826826
Index index2 = it2->data;
@@ -829,7 +829,7 @@ class CompressedRowSparseMatrixMechanical final // final is used to allow the co
829829

830830
public:
831831
/// Get the iterator corresponding to the beginning of the given row of blocks
832-
virtual ColBlockConstIterator bRowBegin(Index ib) const override
832+
ColBlockConstIterator bRowBegin(Index ib) const override
833833
{
834834
if constexpr (Policy::AutoCompress) const_cast<Matrix*>(this)->compress(); /// \warning this violates the const-ness of the method !
835835
Index rowId = Index(ib * this->rowIndex.size() / this->nBlockRow);
@@ -842,7 +842,7 @@ class CompressedRowSparseMatrixMechanical final // final is used to allow the co
842842
}
843843

844844
/// Get the iterator corresponding to the end of the given row of blocks
845-
virtual ColBlockConstIterator bRowEnd(Index ib) const override
845+
ColBlockConstIterator bRowEnd(Index ib) const override
846846
{
847847
if constexpr (Policy::AutoCompress) const_cast<Matrix*>(this)->compress(); /// \warning this violates the const-ness of the method !
848848
Index rowId = Index(ib * this->rowIndex.size() / this->nBlockRow);
@@ -855,7 +855,7 @@ class CompressedRowSparseMatrixMechanical final // final is used to allow the co
855855
}
856856

857857
/// Get the iterators corresponding to the beginning and end of the given row of blocks
858-
virtual std::pair<ColBlockConstIterator, ColBlockConstIterator> bRowRange(Index ib) const override
858+
std::pair<ColBlockConstIterator, ColBlockConstIterator> bRowRange(Index ib) const override
859859
{
860860
if constexpr (Policy::AutoCompress) const_cast<Matrix*>(this)->compress(); /// \warning this violates the const-ness of the method !
861861
Index rowId = Index(ib * this->rowIndex.size() / this->nBlockRow);
@@ -871,28 +871,28 @@ class CompressedRowSparseMatrixMechanical final // final is used to allow the co
871871

872872

873873
protected:
874-
virtual void itCopyRowBlock(InternalRowBlockIterator* /*it*/) const override {}
875-
virtual void itDeleteRowBlock(const InternalRowBlockIterator* /*it*/) const override {}
876-
virtual Index itAccessRowBlock(InternalRowBlockIterator* it) const override
874+
void itCopyRowBlock(InternalRowBlockIterator* /*it*/) const override {}
875+
void itDeleteRowBlock(const InternalRowBlockIterator* /*it*/) const override {}
876+
Index itAccessRowBlock(InternalRowBlockIterator* it) const override
877877
{
878878
Index rowId = it->data[0];
879879
return this->rowIndex[rowId];
880880
}
881-
virtual ColBlockConstIterator itBeginRowBlock(InternalRowBlockIterator* it) const override
881+
ColBlockConstIterator itBeginRowBlock(InternalRowBlockIterator* it) const override
882882
{
883883
Index rowId = it->data[0];
884884
Index row = this->rowIndex[rowId];
885885
Index index = this->rowBegin[rowId];
886886
return createColBlockConstIterator(row, index);
887887
}
888-
virtual ColBlockConstIterator itEndRowBlock(InternalRowBlockIterator* it) const override
888+
ColBlockConstIterator itEndRowBlock(InternalRowBlockIterator* it) const override
889889
{
890890
Index rowId = it->data[0];
891891
Index row = this->rowIndex[rowId];
892892
Index index2 = this->rowBegin[rowId+1];
893893
return createColBlockConstIterator(row, index2);
894894
}
895-
virtual std::pair<ColBlockConstIterator, ColBlockConstIterator> itRangeRowBlock(InternalRowBlockIterator* it) const override
895+
std::pair<ColBlockConstIterator, ColBlockConstIterator> itRangeRowBlock(InternalRowBlockIterator* it) const override
896896
{
897897
Index rowId = it->data[0];
898898
Index row = this->rowIndex[rowId];
@@ -902,25 +902,25 @@ class CompressedRowSparseMatrixMechanical final // final is used to allow the co
902902
createColBlockConstIterator(row, index2));
903903
}
904904

905-
virtual void itIncRowBlock(InternalRowBlockIterator* it) const override
905+
void itIncRowBlock(InternalRowBlockIterator* it) const override
906906
{
907907
Index rowId = it->data[0];
908908
++rowId;
909909
it->data[0] = rowId;
910910
}
911-
virtual void itDecRowBlock(InternalRowBlockIterator* it) const override
911+
void itDecRowBlock(InternalRowBlockIterator* it) const override
912912
{
913913
Index rowId = it->data[0];
914914
--rowId;
915915
it->data[0] = rowId;
916916
}
917-
virtual bool itEqRowBlock(const InternalRowBlockIterator* it, const InternalRowBlockIterator* it2) const override
917+
bool itEqRowBlock(const InternalRowBlockIterator* it, const InternalRowBlockIterator* it2) const override
918918
{
919919
Index rowId = it->data[0];
920920
Index rowId2 = it2->data[0];
921921
return rowId == rowId2;
922922
}
923-
virtual bool itLessRowBlock(const InternalRowBlockIterator* it, const InternalRowBlockIterator* it2) const override
923+
bool itLessRowBlock(const InternalRowBlockIterator* it, const InternalRowBlockIterator* it2) const override
924924
{
925925
Index rowId = it->data[0];
926926
Index rowId2 = it2->data[0];
@@ -929,21 +929,21 @@ class CompressedRowSparseMatrixMechanical final // final is used to allow the co
929929

930930
public:
931931
/// Get the iterator corresponding to the beginning of the rows of blocks
932-
virtual RowBlockConstIterator bRowsBegin() const override
932+
RowBlockConstIterator bRowsBegin() const override
933933
{
934934
if constexpr (Policy::AutoCompress) const_cast<Matrix*>(this)->compress(); /// \warning this violates the const-ness of the method !
935935
return createRowBlockConstIterator(0, 0);
936936
}
937937

938938
/// Get the iterator corresponding to the end of the rows of blocks
939-
virtual RowBlockConstIterator bRowsEnd() const override
939+
RowBlockConstIterator bRowsEnd() const override
940940
{
941941
if constexpr (Policy::AutoCompress) const_cast<Matrix*>(this)->compress(); /// \warning this violates the const-ness of the method !
942942
return createRowBlockConstIterator(Index(this->rowIndex.size()), 0);
943943
}
944944

945945
/// Get the iterators corresponding to the beginning and end of the given row of blocks
946-
virtual std::pair<RowBlockConstIterator, RowBlockConstIterator> bRowsRange() const override
946+
std::pair<RowBlockConstIterator, RowBlockConstIterator> bRowsRange() const override
947947
{
948948
if constexpr (Policy::AutoCompress) const_cast<Matrix*>(this)->compress(); /// \warning this violates the const-ness of the method !
949949
return std::make_pair(createRowBlockConstIterator(0, 0),

Sofa/framework/Type/src/sofa/type/Mat.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -528,17 +528,17 @@ class Mat
528528

529529
bool isDiagonal() const noexcept
530530
{
531-
for (Size i=0; i<L; i++)
531+
for (Size i=0; i<L; ++i)
532532
{
533-
for (Size j=0; j<i-1; j++)
534-
if( rabs( (*this)(i,j) ) > EQUALITY_THRESHOLD ) return false;
535-
for (Size j=i+1; j<C; j++)
533+
for (Size j=0; j<C; ++j)
534+
{
535+
if (j == i) continue;
536536
if( rabs( (*this)(i,j) ) > EQUALITY_THRESHOLD ) return false;
537+
}
537538
}
538539
return true;
539540
}
540541

541-
542542
/// @}
543543

544544
// LINEAR ALGEBRA

0 commit comments

Comments
 (0)