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 }
Matrix3f m
void MatrixXd_set_coeff(C_MatrixXd *m, int i, int j, double coeff)
void demo_MatrixXd()
Definition: example.c:13
Definition: numpy.h:680
int n
C_Map_MatrixXd * Map_MatrixXd_new(double *array, int rows, int cols)
C_MatrixXd * MatrixXd_new(int rows, int cols)
void MatrixXd_print(const C_MatrixXd *m)
Values result
void MatrixXd_delete(C_MatrixXd *m)
void MatrixXd_multiply(const C_MatrixXd *m1, const C_MatrixXd *m2, C_MatrixXd *result)
void print_array(double *array, int n)
Definition: example.c:35
int main()
Definition: example.c:61
void Map_MatrixXd_add(const C_Map_MatrixXd *m1, const C_Map_MatrixXd *m2, C_Map_MatrixXd *result)
void Map_MatrixXd_print(const C_Map_MatrixXd *m)
void MatrixXd_set_zero(C_MatrixXd *m)
void demo_Map_MatrixXd()
Definition: example.c:42
void Map_MatrixXd_delete(C_Map_MatrixXd *m)


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:34:13