Skip to content

Commit

Permalink
Add #include <vector>
Browse files Browse the repository at this point in the history
  • Loading branch information
afabri committed Apr 23, 2024
1 parent fe6523f commit 3eaeb90
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ and nonlinear programming problems with or without constraints.}
- `QuadraticProgramTraits`

\cgalCRPSection{Linear Systems}
- `CGAL::Accelerate_solver_traits`
- `CGAL::Eigen_solver_traits`
- `CGAL::Eigen_diagonalize_traits`
- `CGAL::Eigen_vector`
Expand Down
45 changes: 29 additions & 16 deletions Solver_interface/examples/Solver_interface/accelerate.cpp
Original file line number Diff line number Diff line change
@@ -1,33 +1,46 @@
#include <CGAL/Accelerate_sparse_matrix.h>
#include <CGAL/Accelerate_vector.h>
#include <CGAL/Accelerate_solver_traits.h>

int main()
{
{
CGAL::Accelerate_sparse_matrix<double> sm(3);
CGAL::Accelerate_sparse_matrix<double> A(3);

sm.set_coef(0,0,1);
sm.set_coef(0,1,2);
sm.set_coef(0,2,3);
sm.set_coef(1,1,5);
sm.set_coef(2,2,9);
A.set_coef(0,0,1);
A.set_coef(0,1,2);
A.set_coef(0,2,3);
A.set_coef(1,1,5);
A.set_coef(2,2,9);

sm.assemble_matrix();
A.assemble_matrix();

assert(A.get_coef(1,0) == 0);

CGAL::Accelerate_vector<double> B(3), X(3);
B[0] = 1.0;
B[1] = 2.0;
B[2] = 3.0;

CGAL::Accelerate_solver_traits<double> ast;
double D;
ast.linear_solver(A, B, X, D);
assert(D == 1.0);

assert(sm.get_coef(1,0) == 0);
}
std::cout << std::endl;
{
CGAL::Accelerate_sparse_matrix<double> sm(3, true);// symmetric only set lower left
CGAL::Accelerate_sparse_matrix<double> A(3, true);// symmetric only set lower left

sm.set_coef(0,0,1);
sm.set_coef(1,0,2);
sm.set_coef(2,0,3);
sm.set_coef(1,1,5);
sm.set_coef(2,2,9);
A.set_coef(0,0,1);
A.set_coef(1,0,2);
A.set_coef(2,0,3);
A.set_coef(1,1,5);
A.set_coef(2,2,9);

sm.assemble_matrix();
A.assemble_matrix();

assert(sm.get_coef(1,0) == sm.get_coef(0, 1));
assert(A.get_coef(1,0) == A.get_coef(0, 1));
}

return 0;
Expand Down
1 change: 1 addition & 0 deletions Solver_interface/include/CGAL/Accelerate_vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#ifndef CGAL_ACCELERATE_VECTOR_H
#define CGAL_ACCELERATE_VECTOR_H

#include <vector>

namespace CGAL {
/*!
Expand Down

0 comments on commit 3eaeb90

Please sign in to comment.