example.c
Go to the documentation of this file.
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2009 Benoit Jacob <jacob.benoit.1@gmail.com>
5 //
6 // This Source Code Form is subject to the terms of the Mozilla
7 // Public License v. 2.0. If a copy of the MPL was not distributed
8 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 
10 #include "binary_library.h"
11 #include "stdio.h"
12 
14 {
15  struct C_MatrixXd *matrix1, *matrix2, *result;
16  printf("*** demo_MatrixXd ***\n");
17 
18  matrix1 = MatrixXd_new(3, 3);
19  MatrixXd_set_zero(matrix1);
20  MatrixXd_set_coeff(matrix1, 0, 1, 2.5);
21  MatrixXd_set_coeff(matrix1, 1, 0, 1.4);
22  printf("Here is matrix1:\n");
23  MatrixXd_print(matrix1);
24 
25  matrix2 = MatrixXd_new(3, 3);
26  MatrixXd_multiply(matrix1, matrix1, matrix2);
27  printf("Here is matrix1*matrix1:\n");
28  MatrixXd_print(matrix2);
29 
30  MatrixXd_delete(matrix1);
31  MatrixXd_delete(matrix2);
32 }
33 
34 // this helper function takes a plain C array and prints it in one line
35 void print_array(double *array, int n)
36 {
37  struct C_Map_MatrixXd *m = Map_MatrixXd_new(array, 1, n);
40 }
41 
43 {
44  struct C_Map_MatrixXd *map;
45  double array[5];
46  int i;
47  printf("*** demo_Map_MatrixXd ***\n");
48 
49  for(i = 0; i < 5; ++i) array[i] = i;
50  printf("Initially, the array is:\n");
51  print_array(array, 5);
52 
53  map = Map_MatrixXd_new(array, 5, 1);
54  Map_MatrixXd_add(map, map, map);
56 
57  printf("Now the array is:\n");
58  print_array(array, 5);
59 }
60 
61 int main()
62 {
63  demo_MatrixXd();
65 }
Map_MatrixXd_new
C_Map_MatrixXd * Map_MatrixXd_new(double *array, int rows, int cols)
Definition: binary_library.cpp:137
MatrixXd_new
C_MatrixXd * MatrixXd_new(int rows, int cols)
Definition: binary_library.cpp:72
Map_MatrixXd_add
void Map_MatrixXd_add(const C_Map_MatrixXd *m1, const C_Map_MatrixXd *m2, C_Map_MatrixXd *result)
Definition: binary_library.cpp:182
C_MatrixXd
Definition: binary_library.h:22
demo_MatrixXd
void demo_MatrixXd()
Definition: example.c:13
MatrixXd_print
void MatrixXd_print(const C_MatrixXd *m)
Definition: binary_library.cpp:117
MatrixXd_multiply
void MatrixXd_multiply(const C_MatrixXd *m1, const C_MatrixXd *m2, C_MatrixXd *result)
Definition: binary_library.cpp:122
Map_MatrixXd_print
void Map_MatrixXd_print(const C_Map_MatrixXd *m)
Definition: binary_library.cpp:172
result
Values result
Definition: OdometryOptimize.cpp:8
n
int n
Definition: BiCGSTAB_simple.cpp:1
Map_MatrixXd_delete
void Map_MatrixXd_delete(C_Map_MatrixXd *m)
Definition: binary_library.cpp:142
print_array
void print_array(double *array, int n)
Definition: example.c:35
m
Matrix3f m
Definition: AngleAxis_mimic_euler.cpp:1
array
Definition: numpy.h:821
binary_library.h
MatrixXd_set_coeff
void MatrixXd_set_coeff(C_MatrixXd *m, int i, int j, double coeff)
Definition: binary_library.cpp:107
MatrixXd_set_zero
void MatrixXd_set_zero(C_MatrixXd *m)
Definition: binary_library.cpp:87
MatrixXd_delete
void MatrixXd_delete(C_MatrixXd *m)
Definition: binary_library.cpp:77
demo_Map_MatrixXd
void demo_Map_MatrixXd()
Definition: example.c:42
main
int main()
Definition: example.c:61
i
int i
Definition: BiCGSTAB_step_by_step.cpp:9
C_Map_MatrixXd
Definition: binary_library.h:23


gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:02:16