cmake introduction
A short example project for the CMake build system
main.cxx
Go to the documentation of this file.
1 #include "config.h"
2 #include <iostream>
3 #include "core.h"
4 
5 
6 
7 
8 /**
9  Example program solving a simple linear system.
10 */
11 int main (int argc, char* argv[])
12 {
13 #ifndef NDEBUG
14  std::cout << "Hello from 'cxx-test-project' version "
15  << CXX_TEST_PROJECT << std::endl;
16  std::cout << "build type: " << configure_time_constants::build_type << "\n";
17  std::cout << "git revision: " << configure_time_constants::git_revision << "\n";
18  std::cout << "git branch: " << configure_time_constants::git_branch << "\n";
19 #endif
20  // init matrix and right-hand side
21  core::Matrix<double> matrix(10);
22  core::Vector<double> rhs(10);
23 
24  // set matrix and right-hand side
25  for (int i = 1; i <= 10; i++){
26  rhs(i) = 1.0;
27  matrix(i,i) = i;
28  }
29 #ifndef NDEBUG
30  // print matrix
31  matrix.print_formatted(std::cout);
32 
33  std::cout << std::endl;
34  // print rhs
35  rhs.print_formatted(std::cout);
36  std::cout << std::endl;
37 #endif
38 
39  // solve linear system with LAPACK
40  core::solve_linear_system(matrix, rhs);
41 
42  // print solution to stdout
43  std::cout << "Solution:" <<std::endl;
44  rhs.print_formatted(std::cout);
45 
46  return 0;
47 }
constexpr const char * git_revision
Git revision id.
Definition: config.h:31
int main(int argc, char *argv[])
Definition: main.cxx:11
constexpr const char * build_type
Current build type.
Definition: config.h:35
#define CXX_TEST_PROJECT
Definition: config.h:14
int solve_linear_system(Matrix< double > &A, Vector< double > &rhs)
Definition: core.cxx:9
void print_formatted(OUTPUT_STREAM &os, const unsigned int precision=3, const bool scientific=true, const unsigned int width_=0, const char *zero_string="*", const double denominator=1., const double threshold=0.) const
print the matrix in some nice form
Definition: matrix.h:72
constexpr const char * git_branch
Current Git branch.
Definition: config.h:33
void print_formatted(OUTPUT_STREAM &os, const unsigned int precision=3, const bool scientific=true, const unsigned int width_=0, const char *zero_string="*", const double denominator=1., const double threshold=0.) const
print the matrix in some nice form
Definition: vector.h:69
A dense quadratic matrix of arbitrary size.
Definition: matrix.h:19
A vector of arbitrary size.
Definition: vector.h:18