-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
129 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
|
||
// Copyright (c) 2024 GeometryFactory SARL (France), All rights reserved. | ||
// | ||
// This file is part of CGAL (www.cgal.org) | ||
// | ||
// $URL$ | ||
// $Id$ | ||
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial | ||
// | ||
// Author(s) : Andreas Fabri | ||
|
||
#ifndef CGAL_ACCELERATE_SOLVER_TRAIS_H | ||
#define CGAL_ACCELERATE_SOLVER_TRAIS_H | ||
|
||
|
||
#include <CGAL/Accelerate_vector.h> | ||
#include <CGAL/Accelerate_sparse_matrix.h> | ||
|
||
namespace CGAL { | ||
|
||
/*! | ||
\ingroup PkgSolverInterfaceLS | ||
The class `Accelerate_solver_traits` provides an interface to the sparse solvers of | ||
*/ | ||
template<class T> | ||
class Accelerate_solver_traits | ||
{ | ||
public: | ||
using NT = T; | ||
using Matrix = Accelerate_sparse_matrix<T>; | ||
using Vector = Accelerate_vector<T>; | ||
|
||
Accelerate_solver_traits() | ||
{} | ||
|
||
/// Solve the sparse linear system \f$ A \times X = B \f$. | ||
/// Return `true` on success. The solution is then \f$ (1/D) \times X \f$. | ||
/// | ||
/// \pre A.row_dimension() == B.dimension(). | ||
/// \pre A.column_dimension() == X.dimension(). | ||
bool linear_solver(const Matrix& A, const Vector& B, Vector& X, NT& D) | ||
{ | ||
D = 1; // Accelerate does not support homogeneous coordinates | ||
return true; | ||
} | ||
|
||
}; | ||
|
||
} // namespace CGAL | ||
|
||
|
||
#endif // ACCELERATE_SOLVER_TRAITS |
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,76 @@ | ||
// Copyright (c) 2024 GeometryFactory SARL (France), All rights reserved. | ||
// | ||
// This file is part of CGAL (www.cgal.org) | ||
// | ||
// $URL$ | ||
// $Id$ | ||
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial | ||
// | ||
// Author(s) : Andreas Fabri | ||
|
||
#ifndef CGAL_ACCELERATE_VECTOR_H | ||
#define CGAL_ACCELERATE_VECTOR_H | ||
|
||
|
||
namespace CGAL { | ||
/*! | ||
\ingroup PkgSolverInterfaceLS | ||
The class `Accelerate_vector` is a vector of numbers. | ||
\cgalModels{SvdTraits::Vector,SparseLinearAlgebraTraits_d::Vector} | ||
\tparam T Number type. Must be `double` or `float` | ||
\sa `CGAL::Accelerate_solver_traits<T>` | ||
\sa `CGAL::Accelerate_sparse_matrix<T>` | ||
*/ | ||
|
||
template<class T> | ||
class Accelerate_vector | ||
|
||
{ | ||
// Public types | ||
public: | ||
/// \name Types | ||
/// @{ | ||
typedef T NT; | ||
|
||
/// @} | ||
|
||
// Public operations | ||
public: | ||
|
||
/// Constructs a null vector. | ||
Accelerate_vector() = default; | ||
|
||
/// Create a vector initialized with zeros. | ||
Accelerate_vector(std::size_t dimension) | ||
: m_vec(dimension, NT(0)) | ||
{} | ||
|
||
|
||
/// Return the vector's number of coefficients. | ||
int dimension() const { return static_cast<int>(m_vec.size()); } | ||
|
||
NT operator[](int row) const | ||
{ | ||
return m_vec[row]; | ||
} | ||
|
||
|
||
NT& operator[](int row) | ||
{ | ||
return m_vec[row]; | ||
} | ||
|
||
/// Return a pointer to the data array of this vector. | ||
const NT* data() { return &m_vec[0]; } | ||
|
||
private: | ||
std::vector<NT> m_vec; | ||
}; | ||
|
||
} // namespace CGAL | ||
|
||
#endif // CGAL_ACCELERATE_VECTOR_H |