Skip to content
Snippets Groups Projects
Commit abaeaa15 authored by nicolas.rivier's avatar nicolas.rivier
Browse files
parents 87b27012 d4a45d66
No related branches found
No related tags found
No related merge requests found
File added
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <math.h>
#include <time.h> #include <time.h>
#include "vector.h"
#include "equation.h" #include "equation.h"
int main(int argc, char **argv[]) { int main(int argc, char **argv[]) {
...@@ -55,5 +57,11 @@ int main(int argc, char **argv[]) { ...@@ -55,5 +57,11 @@ int main(int argc, char **argv[]) {
printf("%f\n", f(x)); printf("%f\n", f(x));
printf("%f\n", fd(x)); printf("%f\n", fd(x));
double_vector_t *X = create_vector_x(points, NB_POINTS);
double_vector_t *Y = create_vector_y(points, NB_POINTS);
export_vector("../X.vec", X);
export_vector("../Y.vec", Y);
free(points); free(points);
destroy_vector(&X);
destroy_vector(&Y);
} }
\ No newline at end of file
...@@ -69,6 +69,25 @@ double_vector_t *apply_function(double_vector_t *vec, double_function_t f) ...@@ -69,6 +69,25 @@ double_vector_t *apply_function(double_vector_t *vec, double_function_t f)
} }
return res; return res;
} }
double_vector_t *create_vector_x(point_t *points, int N) {
double_vector_t *res = init_vector(N);
for (uint32_t i = 0; i < N; i++)
{
res->components[i] = points[i].x;
}
return res;
}
double_vector_t *create_vector_y(point_t *points, int N) {
double_vector_t *res = init_vector(N);
for (uint32_t i = 0; i < N; i++)
{
res->components[i] = points[i].y;
}
return res;
}
/** @brief /** @brief
* Export a vector into a file. * Export a vector into a file.
* *
......
#include <stdint.h> #include <stdint.h>
#include "equation.h"
typedef struct double_vector typedef struct double_vector
{ {
...@@ -60,3 +61,6 @@ void export_vector(const char *filename, double_vector_t *vec); ...@@ -60,3 +61,6 @@ void export_vector(const char *filename, double_vector_t *vec);
* @param vec A double pointer on a vector * @param vec A double pointer on a vector
*/ */
void destroy_vector(double_vector_t **vec); void destroy_vector(double_vector_t **vec);
double_vector_t *create_vector_x(point_t *points, int N);
double_vector_t *create_vector_y(point_t *points, int N);
\ No newline at end of file
File added
...@@ -4,7 +4,7 @@ from load_vec import load_vector ...@@ -4,7 +4,7 @@ from load_vec import load_vector
X = load_vector("../X.vec") X = load_vector("../X.vec")
Y = load_vector("../Y.vec") Y = load_vector("../Y.vec")
type_of_data = 'curve' type_of_data = 'cure' # curve = point connecté
if type_of_data == 'curve': if type_of_data == 'curve':
plt.plot(X, Y, label="my curve") plt.plot(X, Y, label="my curve")
......
src/X.vec 0 → 100644
File added
src/Y.vec 0 → 100644
File added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment