Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "binary_library.h"
00026 #include "stdio.h"
00027
00028 void demo_MatrixXd()
00029 {
00030 struct C_MatrixXd *matrix1, *matrix2, *result;
00031 printf("*** demo_MatrixXd ***\n");
00032
00033 matrix1 = MatrixXd_new(3, 3);
00034 MatrixXd_set_zero(matrix1);
00035 MatrixXd_set_coeff(matrix1, 0, 1, 2.5);
00036 MatrixXd_set_coeff(matrix1, 1, 0, 1.4);
00037 printf("Here is matrix1:\n");
00038 MatrixXd_print(matrix1);
00039
00040 matrix2 = MatrixXd_new(3, 3);
00041 MatrixXd_multiply(matrix1, matrix1, matrix2);
00042 printf("Here is matrix1*matrix1:\n");
00043 MatrixXd_print(matrix2);
00044
00045 MatrixXd_delete(matrix1);
00046 MatrixXd_delete(matrix2);
00047 }
00048
00049
00050 void print_array(double *array, int n)
00051 {
00052 struct C_Map_MatrixXd *m = Map_MatrixXd_new(array, 1, n);
00053 Map_MatrixXd_print(m);
00054 Map_MatrixXd_delete(m);
00055 }
00056
00057 void demo_Map_MatrixXd()
00058 {
00059 struct C_Map_MatrixXd *map;
00060 double array[5];
00061 int i;
00062 printf("*** demo_Map_MatrixXd ***\n");
00063
00064 for(i = 0; i < 5; ++i) array[i] = i;
00065 printf("Initially, the array is:\n");
00066 print_array(array, 5);
00067
00068 map = Map_MatrixXd_new(array, 5, 1);
00069 Map_MatrixXd_add(map, map, map);
00070 Map_MatrixXd_delete(map);
00071
00072 printf("Now the array is:\n");
00073 print_array(array, 5);
00074 }
00075
00076 int main()
00077 {
00078 demo_MatrixXd();
00079 demo_Map_MatrixXd();
00080 }