-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #140 from epernod/v22.06
Fix headers includes and namespaces to follow changes in SOFA
- Loading branch information
Showing
64 changed files
with
286 additions
and
217 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#pragma once | ||
|
||
#include <SofaCaribou/config.h> | ||
|
||
// Various utilities to perform numerical operations on SOFA's BaseMatrix. | ||
DISABLE_ALL_WARNINGS_BEGIN | ||
#include <sofa/version.h> // for SOFA_VERSION | ||
DISABLE_ALL_WARNINGS_END | ||
|
||
#if (defined(SOFA_VERSION) && SOFA_VERSION < 211200) | ||
#include <sofa/defaulttype/BaseMatrix.h> | ||
#else | ||
#include <sofa/linearalgebra/BaseMatrix.h> | ||
#endif // (defined(SOFA_VERSION) && SOFA_VERSION < 211299) | ||
|
||
namespace SofaCaribou::Algebra | ||
{ | ||
|
||
#if (defined(SOFA_VERSION) && SOFA_VERSION < 211200) | ||
using BaseMatrix = sofa::defaulttype::BaseMatrix; | ||
#else | ||
using BaseMatrix = sofa::linearalgebra::BaseMatrix; | ||
#endif // (defined(SOFA_VERSION) && SOFA_VERSION < 211299) | ||
|
||
|
||
} // namespace SofaCaribou::Algebra |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,11 +4,10 @@ | |
DISABLE_ALL_WARNINGS_BEGIN | ||
#include <sofa/version.h> | ||
#if (defined(SOFA_VERSION) && SOFA_VERSION < 211299) | ||
#include <sofa/defaulttype/BaseVector.h> | ||
#include <SofaBaseLinearSolver/FullVector.h> | ||
#else | ||
#include <sofa/linearalgebra/BaseVector.h> | ||
#include <sofa/linearalgebra/FullVector.h> | ||
#endif // #if (defined(SOFA_VERSION) && SOFA_VERSION < 211299) | ||
#include <SofaBaseLinearSolver/FullVector.h> | ||
DISABLE_ALL_WARNINGS_END | ||
|
||
#if (defined(SOFA_VERSION) && SOFA_VERSION < 201200) | ||
|
@@ -21,14 +20,20 @@ using Index = sofa::defaulttype::BaseVector::Index; | |
namespace SofaCaribou::Algebra { | ||
|
||
namespace { // Anonymous | ||
#if (defined(SOFA_VERSION) && SOFA_VERSION < 211299) | ||
using namespace sofa::component::linearsolver; | ||
#else | ||
using namespace sofa::linearalgebra; | ||
#endif | ||
|
||
template <typename Real> | ||
auto to_full_vector(const sofa::defaulttype::BaseVector* v) -> const sofa::component::linearsolver::FullVector<Real> * { | ||
return dynamic_cast<const sofa::component::linearsolver::FullVector<Real> *>(v); | ||
auto to_full_vector(const BaseVector* v) -> const FullVector<Real> * { | ||
return dynamic_cast<const FullVector<Real> *>(v); | ||
} | ||
|
||
// Dot product between a SOFA full vector and any BaseVector | ||
template <typename ReturnValue, typename Real> | ||
ReturnValue dot(const sofa::component::linearsolver::FullVector<Real> * v1, const sofa::defaulttype::BaseVector * v2) { | ||
ReturnValue dot(const FullVector<Real> * v1, const BaseVector * v2) { | ||
const auto n = static_cast<sofa::Size>(v1->size()); | ||
auto value = static_cast<ReturnValue>(0); | ||
for (sofa::Index i = 0; i < n; ++i) { | ||
|
@@ -40,7 +45,7 @@ ReturnValue dot(const sofa::component::linearsolver::FullVector<Real> * v1, cons | |
|
||
// Dot product between a two SOFA full vectors | ||
template <typename ReturnValue, typename Real1, typename Real2> | ||
ReturnValue dot(const sofa::component::linearsolver::FullVector<Real1> * v1, const sofa::component::linearsolver::FullVector<Real2> * v2) { | ||
ReturnValue dot(const FullVector<Real1> * v1, const FullVector<Real2> * v2) { | ||
const auto n = static_cast<sofa::Size>(v1->size()); | ||
auto value = static_cast<ReturnValue>(0); | ||
for (sofa::Index i = 0; i < n; ++i) { | ||
|
@@ -52,7 +57,7 @@ ReturnValue dot(const sofa::component::linearsolver::FullVector<Real1> * v1, con | |
} | ||
|
||
/** Compute the dot product between two BaseVector, i.e. scalar = v1.dot(v2) */ | ||
double dot(const sofa::defaulttype::BaseVector * v1, const sofa::defaulttype::BaseVector * v2) { | ||
double dot(const BaseVector * v1, const BaseVector * v2) { | ||
caribou_assert(v1->size() == v2->size()); | ||
|
||
// todo([email protected]): This function is awful. I'm sure there is a much much cleaner and faster way | ||
|
@@ -119,4 +124,4 @@ ReturnValue dot(const sofa::component::linearsolver::FullVector<Real1> * v1, con | |
return static_cast<double> (value); | ||
} | ||
|
||
} // namespace SofaCaribou::Algebra | ||
} // namespace SofaCaribou::Algebra |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.