Moved linspace function into module
This commit is contained in:
parent
62020d51e5
commit
d2a050d1da
10
include/linalg.h
Normal file
10
include/linalg.h
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
#include <gsl/gsl_matrix.h>
|
||||||
|
|
||||||
|
#ifndef LINALG_H
|
||||||
|
#define LINALG_H
|
||||||
|
|
||||||
|
int
|
||||||
|
linspace
|
||||||
|
( double start, double end, int length, gsl_matrix *out );
|
||||||
|
|
||||||
|
#endif
|
||||||
12
src/linalg.c
Normal file
12
src/linalg.c
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
#include "linalg.h"
|
||||||
|
|
||||||
|
int linspace ( double start, double end, int length, gsl_matrix *out ) {
|
||||||
|
if ( out->size2 != length )
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
double by = end / length;
|
||||||
|
for ( int i = 0 ; i < length ; i++ )
|
||||||
|
(void)gsl_matrix_set(out, 0, i, i*by);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user