Algorithms_in_C
1.0.0
Set of algorithms implemented in C.
|
Go to the documentation of this file.
10 #define QR_DECOMPOSE_H
26 for (
int row = 0; row < M; row++)
28 for (
int col = 0; col <
N; col++) printf(
"% 9.3g\t", A[row][col]);
49 #pragma omp parallel for reduction(+ : mag)
51 for (i = 0; i <
L; i++) mag += a[i] * b[i];
83 const double scalar = num / deno;
89 for (i = 0; i <
L; i++) out[i] = scalar * b[i];
112 for (i = 0; i <
L; i++) out[i] = a[i] - b[i];
149 double *col_vector = (
double *)malloc(M *
sizeof(
double));
150 double *col_vector2 = (
double *)malloc(M *
sizeof(
double));
151 double *tmp_vector = (
double *)malloc(M *
sizeof(
double));
152 for (
int i = 0; i <
N;
160 for (j = 0; j < i; j++)
168 for (j = 0; j < M; j++)
170 tmp_vector[j] = A[j][i];
171 col_vector[j] = A[j][i];
173 for (j = 0; j < i; j++)
175 for (
int k = 0; k < M; k++) col_vector2[k] = Q[k][j];
176 vector_proj(col_vector, col_vector2, col_vector2, M);
177 vector_sub(tmp_vector, col_vector2, tmp_vector, M);
185 for (j = 0; j < M; j++) Q[j][i] = tmp_vector[j] / mag;
188 for (
int kk = 0; kk < M; kk++) col_vector[kk] = Q[kk][i];
189 for (
int k = i; k <
N; k++)
191 for (
int kk = 0; kk < M; kk++) col_vector2[kk] = A[kk][k];
192 R[i][k] =
vector_dot(col_vector, col_vector2, M);
201 #endif // QR_DECOMPOSE_H
int main(int argc, char *argv[])
Definition: collatz.c:16
Definition: factorial_large_number.c:15
void test2()
Definition: kohonen_som_trace.c:349
char * get_weights_str(struct adaline *ada)
Definition: adaline_learning.c:99
int save_nd_data(const char *fname, double **X, int num_points, int num_features)
Definition: kohonen_som_trace.c:65
double * weights
weights of the neural network
Definition: adaline_learning.c:39
void forward_euler_step(const double dx, const double *x, double *y, double *dy)
Compute next step approximation using the forward-Euler method.
Definition: ode_forward_euler.c:82
#define max(a, b)
Definition: kohonen_som_trace.c:24
void test3()
Definition: kohonen_som_topology.c:601
void exact_solution(const double *x, double *y)
Exact solution of the problem. Used for solution comparison.
Definition: ode_midpoint_euler.c:67
int compare(const void *a, const void *b)
Definition: sol1.c:19
int main(int argc, char **argv)
Definition: lu_decompose.c:79
int main(int argc, char *argv[])
Definition: ode_semi_implicit_euler.c:147
#define min(a, b)
Definition: kohonen_som_topology.c:37
double vector_mag(double *vector, int L)
Definition: qr_decompose.h:64
void delete_adaline(struct adaline *ada)
Definition: adaline_learning.c:81
void test_circle(double *const *data, int N)
Definition: kohonen_som_trace.c:214
double forward_euler(double dx, double x0, double x_max, double *y, char save_to_file)
Compute approximation using the forward-Euler method in the given limits.
Definition: ode_forward_euler.c:99
double update_weights(const double *X, struct array_3d *W, double **D, int num_out, int num_features, double alpha, int R)
Definition: kohonen_som_topology.c:231
double * data
Definition: kohonen_som_topology.c:49
Definition: prime_factoriziation.c:25
double complex d_func(double complex x)
Definition: newton_raphson_root.c:32
int main(int argc, char **argv)
Definition: kohonen_som_topology.c:661
int main(int argc, char **argv)
Definition: adaline_learning.c:378
double * data_3d(const struct array_3d *arr, int x, int y, int z)
Definition: kohonen_som_topology.c:64
void kohonen_som_tracer(double **X, double *const *W, int num_samples, int num_features, int num_out, double alpha_min)
Definition: kohonen_som_trace.c:175
void test_3d_classes1(double *const *data, int N)
Definition: kohonen_som_topology.c:457
void update_weights(double const *x, double *const *W, double *D, int num_out, int num_features, double alpha, int R)
Definition: kohonen_som_trace.c:124
long double complex poly_function(double *coeffs, unsigned int degree, long double complex x)
Definition: durand_kerner_roots.c:50
Definition: binary_search_tree.c:14
double * vector_proj(double *a, double *b, double *out, int L)
Definition: qr_decompose.h:76
unsigned int num_digits
Definition: factorial_large_number.c:17
void test3()
Definition: kohonen_som_trace.c:453
void test_3d_classes2(double *const *data, int N)
Definition: kohonen_som_topology.c:556
#define N
Definition: sol1.c:109
void get_min_1d(double const *X, int N, double *val, int *idx)
Definition: kohonen_som_trace.c:99
void qr_decompose(double **A, double **Q, double **R, int M, int N)
Definition: qr_decompose.h:142
const char * complex_str(long double complex x)
Definition: durand_kerner_roots.c:66
int main(int argc, char *argv[])
Definition: fibonacci_fast.c:61
struct _large_num large_num
int save_u_matrix(const char *fname, struct array_3d *W)
Definition: kohonen_som_topology.c:136
large_num * new_number(void)
Definition: factorial_large_number.c:24
char check_termination(long double delta)
Definition: durand_kerner_roots.c:83
double semi_implicit_euler(double dx, double x0, double x_max, double *y, char save_to_file)
Compute approximation using the semi-implicit-Euler method in the given limits.
Definition: ode_semi_implicit_euler.c:109
int main(int argc, char *argv[])
Definition: factorial_large_number.c:94
void multiply(large_num *num, unsigned long n)
Definition: factorial_large_number.c:66
double _random(double a, double b)
Definition: kohonen_som_trace.c:50
void test_lamniscate(double *const *data, int N)
Definition: kohonen_som_trace.c:310
unsigned long lcm(unsigned long a, unsigned long b)
Definition: sol.c:31
void midpoint_euler_step(double dx, double *x, double *y, double *dy)
Compute next step approximation using the midpoint-Euler method.
Definition: ode_midpoint_euler.c:83
int main(int argc, char **argv)
Definition: newton_raphson_root.c:37
int main(int argc, char **argv)
Definition: kohonen_som_trace.c:508
void fib(unsigned long n, unsigned long *C, unsigned long *D)
Definition: fibonacci_fast.c:20
void print_matrix(double **A, int M, int N)
Definition: qr_decompose.h:22
double vector_dot(double *a, double *b, int L)
Definition: qr_decompose.h:43
double eta
learning rate of the algorithm
Definition: adaline_learning.c:38
int dim3
Definition: kohonen_som_topology.c:48
void exact_solution(const double *x, double *y)
Exact solution of the problem. Used for solution comparison.
Definition: ode_semi_implicit_euler.c:71
int main(int argc, char *argv[])
Definition: ode_midpoint_euler.c:144
int dim1
Definition: kohonen_som_topology.c:46
void test2()
Definition: kohonen_som_topology.c:498
void problem(const double *x, double *y, double *dy)
Problem statement for a system with first-order differential equations. Updates the system differenti...
Definition: ode_forward_euler.c:55
void get_min_2d(double **X, int N, double *val, int *x_idx, int *y_idx)
Definition: kohonen_som_topology.c:201
void problem(const double *x, double *y, double *dy)
Problem statement for a system with first-order differential equations. Updates the system differenti...
Definition: ode_semi_implicit_euler.c:58
double _random(double a, double b)
Definition: kohonen_som_topology.c:84
double get_clock_diff(clock_t start_t, clock_t end_t)
Definition: kohonen_som_trace.c:502
#define order
Definition: ode_semi_implicit_euler.c:47
#define MAX_LEN
Definition: sol1.c:15
void search(node *root, int ele)
Definition: threaded_binary_trees.c:98
unsigned long gcd(unsigned long a, unsigned long b)
Definition: sol.c:11
int predict(struct adaline *ada, const double *x, double *out)
Definition: adaline_learning.c:123
void delete_number(large_num *num)
Definition: factorial_large_number.c:37
int lu_decomposition(double **A, double **L, double **U, int mat_size)
Definition: lu_decompose.c:20
Definition: kohonen_som_topology.c:45
struct adaline new_adaline(const int num_features, const double eta)
Definition: adaline_learning.c:51
double * vector_sub(double *a, double *b, double *out, int L)
Definition: qr_decompose.h:101
int main(int argc, char **argv)
Definition: durand_kerner_roots.c:95
void test3(double eta)
Definition: adaline_learning.c:316
int main(int argc, char **argv)
Definition: c_atoi_str_to_integer.c:70
void display(double **A, int N)
Definition: lu_decompose.c:66
#define order
Definition: ode_midpoint_euler.c:43
void exact_solution(const double *x, double *y)
Exact solution of the problem. Used for solution comparison.
Definition: ode_forward_euler.c:68
void test1()
Definition: kohonen_som_trace.c:252
#define min(a, b)
Definition: kohonen_som_trace.c:30
int main(int argc, char *argv[])
Definition: ode_forward_euler.c:137
double fit_sample(struct adaline *ada, const double *x, const int y)
Definition: adaline_learning.c:144
int save_2d_data(const char *fname, double **X, int num_points, int num_features)
Definition: kohonen_som_topology.c:99
double complex func(double complex x)
Definition: newton_raphson_root.c:22
int activation(double x)
Definition: adaline_learning.c:94
Definition: cantor_set.c:6
void test1(double eta)
Definition: adaline_learning.c:205
void test2(double eta)
Definition: adaline_learning.c:253
#define ACCURACY
Definition: durand_kerner_roots.c:41
double midpoint_euler(double dx, double x0, double x_max, double *y, char save_to_file)
Compute approximation using the midpoint-Euler method in the given limits.
Definition: ode_midpoint_euler.c:106
#define ACCURACY
Definition: newton_raphson_root.c:16
void test_3d_classes(double *const *data, int N)
Definition: kohonen_som_trace.c:401
void swap(int *a, int *b)
Definition: shell_sort2.c:21
#define max(a, b)
Definition: kohonen_som_topology.c:31
void fit(struct adaline *ada, double **X, const int *y, const int N)
Definition: adaline_learning.c:170
Definition: adaline_learning.c:37
void semi_implicit_euler_step(double dx, double *x, double *y, double *dy)
Compute next step approximation using the semi-implicit-Euler method.
Definition: ode_semi_implicit_euler.c:85
#define ACCURACY
convergence accuracy
Definition: adaline_learning.c:43
void test1()
Definition: kohonen_som_topology.c:398
int dim2
Definition: kohonen_som_topology.c:47
char * digits
Definition: factorial_large_number.c:16
void kohonen_som(double **X, struct array_3d *W, int num_samples, int num_features, int num_out, double alpha_min)
Definition: kohonen_som_topology.c:311
void problem(const double *x, double *y, double *dy)
Problem statement for a system with first-order differential equations. Updates the system differenti...
Definition: ode_midpoint_euler.c:54
#define order
Definition: ode_forward_euler.c:44
int num_weights
number of weights of the neural network
Definition: adaline_learning.c:40
void add_digit(large_num *num, unsigned int value)
Definition: factorial_large_number.c:48
double get_clock_diff(clock_t start_t, clock_t end_t)
Definition: kohonen_som_topology.c:655
void test_2d_classes(double *const *data, int N)
Definition: kohonen_som_topology.c:358