Commit c4246ef8 authored by Giovanne Marcelo's avatar Giovanne Marcelo

change matrix to gsl matrix

parent 5fe73de5
Pipeline #6344 failed with stage
in 4 minutes and 47 seconds
......@@ -35,7 +35,7 @@ CFLAGS = -std=c99 -g -O3 \
-Wunsafe-loop-optimizations \
-Wvolatile-register-var \
-Wwrite-strings
LFLAGS = -lpq -ljansson
LFLAGS = -lpq -ljansson -lgsl -lgslcblas -lm
INCL = -I./include
SRC = ./src
DEPS = ./include/db_interface.h ./include/log.h ./include/main.h ./include/data_prepare.h ./include/matrix.h
......
......@@ -3,12 +3,10 @@
#include <stdlib.h>
#include <stdio.h>
#include <gsl/gsl_matrix.h>
#include <gsl/gsl_blas.h>
typedef struct {
int ** data;
long unsigned int rows;
long unsigned int cols;
}matrix;
typedef gsl_matrix* matrix;
matrix matrix_alloc(long unsigned int rows, long unsigned int cols);
void print_matrix(matrix m);
......
......@@ -3,5 +3,8 @@
int main(int argc, char **argv) {
matrix m = cartesian_product(10,10);
print_matrix(m);
return 0;
}
......@@ -9,20 +9,13 @@
#include "matrix.h"
matrix matrix_alloc(long unsigned int rows, long unsigned int cols) {
long unsigned int i;
matrix M;
M.rows = rows;
M.cols = cols;
M.data = (int **)malloc(M.rows * sizeof(int*));
for(i = 0; i < M.rows; i++) M.data[i] = (int *)malloc(M.cols * sizeof(int));
return M;
return gsl_matrix_alloc(rows, cols);
}
void print_matrix(matrix m) {
long unsigned int i,j;
for( i = 0; i < m.rows; i++) {
for( j = 0; j < m.cols; j++)
printf("%d ", m.data[i][j]);
printf("\n");
for (size_t i=0; i<m->size1;++i){
for (size_t j=0; j<m->size2; ++j)
printf(" %8lf|",gsl_matrix_get(m,i,j));
puts(" ");
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment