2022-07-05 08:13:25 +02:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <math.h>
|
2022-09-28 10:20:08 +02:00
|
|
|
|
2022-10-24 12:54:51 +02:00
|
|
|
#include "../include/colors.h"
|
2022-09-16 14:53:35 +02:00
|
|
|
#include "include/initialisation.h"
|
2022-07-05 08:13:25 +02:00
|
|
|
|
|
|
|
|
2022-09-26 18:00:31 +02:00
|
|
|
void initialisation_1d_matrix(int initialisation, float* matrix, int rows, int n) { // TODO
|
2022-09-28 10:20:08 +02:00
|
|
|
printf_warning("Appel de initialisation_1d_matrix, incomplet\n");
|
2022-07-05 08:13:25 +02:00
|
|
|
float lower_bound = -6/sqrt((double)n);
|
|
|
|
float distance = -lower_bound-lower_bound;
|
2022-09-09 17:39:07 +02:00
|
|
|
for (int i=0; i < rows; i++) {
|
2022-07-05 08:13:25 +02:00
|
|
|
matrix[i] = lower_bound + RAND_FLT()*distance;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-26 18:00:31 +02:00
|
|
|
void initialisation_2d_matrix(int initialisation, float** matrix, int rows, int columns, int n) { // TODO
|
2022-09-28 10:20:08 +02:00
|
|
|
printf_warning("Appel de initialisation_2d_matrix, incomplet\n");
|
2022-07-05 08:13:25 +02:00
|
|
|
float lower_bound = -6/sqrt((double)n);
|
|
|
|
float distance = -lower_bound-lower_bound;
|
2022-09-09 17:39:07 +02:00
|
|
|
for (int i=0; i < rows; i++) {
|
|
|
|
for (int j=0; j < columns; j++) {
|
2022-07-05 08:13:25 +02:00
|
|
|
matrix[i][j] = lower_bound + RAND_FLT()*distance;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-26 18:00:31 +02:00
|
|
|
void initialisation_3d_matrix(int initialisation, float*** matrix, int depth, int rows, int columns, int n) { // TODO
|
2022-09-28 10:20:08 +02:00
|
|
|
printf_warning("Appel de initialisation_3d_matrix, incomplet\n");
|
2022-07-05 08:13:25 +02:00
|
|
|
float lower_bound = -6/sqrt((double)n);
|
|
|
|
float distance = -lower_bound-lower_bound;
|
2022-09-09 17:39:07 +02:00
|
|
|
for (int i=0; i < depth; i++) {
|
|
|
|
for (int j=0; j < rows; j++) {
|
|
|
|
for (int k=0; k < columns; k++) {
|
2022-07-05 08:13:25 +02:00
|
|
|
matrix[i][j][k] = lower_bound + RAND_FLT()*distance;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-26 18:00:31 +02:00
|
|
|
void initialisation_4d_matrix(int initialisation, float**** matrix, int rows, int columns, int rows1, int columns1, int n) { // TODO
|
2022-09-28 10:20:08 +02:00
|
|
|
printf_warning("Appel de initialisation_4d_matrix, incomplet\n");
|
2022-07-05 08:13:25 +02:00
|
|
|
float lower_bound = -6/sqrt((double)n);
|
|
|
|
float distance = -lower_bound-lower_bound;
|
2022-09-09 17:39:07 +02:00
|
|
|
for (int i=0; i < rows; i++) {
|
|
|
|
for (int j=0; j < columns; j++) {
|
|
|
|
for (int k=0; k < rows1; k++) {
|
|
|
|
for (int l=0; l < columns1; l++) {
|
2022-07-05 08:13:25 +02:00
|
|
|
matrix[i][j][k][l] = lower_bound + RAND_FLT()*distance;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|