Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Arithmos _αριθμός_

Arithmos is a set of APIs that target different taxonomies of algorithms to solve problems through providing _algorithm generic utilities_, and several implementations for the common _abstract data types (adt)_ commonly encountered during solving problems while building commericial applications or participating in problem solving contests.
Arithmos is a set of APIs that target different taxonomies of algorithms to solve problems through providing _algorithm generic utilities_, and several implementations for the common _abstract data types (adt)_ commonly encountered during solving problems while building commercial applications or participating in problem solving contests.

Arithmos is essentially composed of the following:
- [x] Vector2d Library (Finished).
- [ ] Vector3d Library.
- [ ] MatrixNd Library.
- [x] Vector3d Library (Partially Finished).
- [x] MatrixNd Library (Partially Finished).
- [ ] Discrete Sets Operations (Conjunctive, Disjunctive, Subtraction, Powersets, De'Morgans formulas).
- [ ] Physics Simulation Library (Collision detection - Force Control - Objects interactions).
- [ ] Statistics Algoritms Library (Present in Java - WIP to port).
- [ ] Statistics Algorithms Library (Present in Java - WIP to port).
- [ ] Differential and Integral Calculus Library.
- [ ] Generic Algorithms Utilities Library.
- [ ] Linear Algorithms Library.
Expand Down Expand Up @@ -52,7 +52,7 @@ Most of these libraries rely on the _Generic Algorithms Utilities Library_; this
- Hashing Algorithms.
- [ ] Modular Arithmetics.
- Un-hashing Algorithms.
- Switching Algebra ALgorithms.
- Switching Algebra Algorithms.
- [ ] Elementary Bit switching.
- [ ] Elementary Bit shifting.
- [ ] Elementary Byte switching.
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#ifndef _MAT_ND_H_
#define _MAT_ND_H_

#include <math.h>
#include <electrostatic/electronetsoft/util/types.h>
#include <electrostatic/electronetsoft/util/caller_graphs.h>
#include <electrostatic/electronetsoft/util/utilities.h>
#include <electrostatic/electronetsoft/algorithm/arithmos/vectorspaces/vector2d/vector2d.h>
#include <electrostatic/electronetsoft/algorithm/arithmos/vectorspaces/vector3d/vector3d.h>

#ifdef __cplusplus
extern "C" {
#endif

struct matrix {
vec_component **element;
uint64_t m;
uint64_t n;
};

struct mat_processors {
status_code (*on_entry_iterated)(mat_proc_sig);
status_code (*on_row_iterated)(mat_proc_sig);
status_code (*on_column_iterated)(mat_proc_sig);
status_code (*on_binary_op_preprocessor)(mat_binary_op_sig);
status_code (*on_binary_op_postprocessor)(mat_binary_op_sig);
status_code (*on_unary_op_preprocessor)(mat_proc_sig);
status_code (*on_elementary_op_postprocessor)(mat_proc_sig);
void (*on_op_success)(mat_proc_sig);
void (*on_op_failure)(mat_proc_sig, status_code);
caller_graph *root;
void *metadata;
};

struct mat_binary_op_sig {
matrix m0;
matrix m1;
uint64_t row_index;
uint64_t col_index;
mat_processors proc;
void *metadata;
};

struct mat_proc_sig {
matrix mat;
uint64_t row_index;
uint64_t col_index;
mat_processors proc;
caller_graph caller;
void *metadata;
};

static inline status_code is_last_column(matrix mat, uint64_t index) {
return index != 0 // the last column is never at the first index!
&& (index % (mat.n - 1) == 0)
&& ASSERTION_SUCCESS;
}

static inline status_code is_last_row(matrix mat, uint64_t index) {
return index != 0 // the last row is never at the first index!
&& (index % (mat.m - 1) == 0)
&& ASSERTION_SUCCESS;
}

status_code mat_add(matrix, matrix, matrix *, mat_processors);
status_code mat_subtract(matrix, matrix, matrix *, mat_processors);
status_code mat_product(matrix, matrix, matrix *, mat_processors);
status_code mat_scalar_prod(matrix, vec_component, matrix *, mat_processors);
status_code mat_scalar_divide(matrix, vec_component, matrix *, mat_processors);
status_code mat_create_rotator_matrix(vec_component, matrix *, mat_processors *);
status_code mat_create_from_vector2d(vector2d, matrix *, mat_processors);
status_code mat_create_from_vector3d(vector3d, matrix *, mat_processors);
status_code mat_iterate_rows(matrix, mat_processors);
status_code mat_iterate_columns(matrix, mat_processors);
status_code mat_iterate_elements(matrix, mat_iterator, mat_processors);

#ifdef __cplusplus
};
#endif

#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#if !(defined __VECTOR_2D_H_ || defined __VECTOR_3D_H_)
# error "Use vector2d or vector3d instead of this!"
#endif

#ifndef __VEC_COMPONENT_H_
#define __VEC_COMPONENT_H_

#include <math.h>
#include <inttypes.h>

#if defined (_VECTOR2D_USE_UINT8_)
# define vec_component uint8_t
# define mod_vec_component vec_component
# define vector2d_pow(v, p) ((uint8_t) powf(v, p))
# define vector2d_atan2(y, x) ((uint8_t) atan2f(y, x))
# define vector2d_acos(v) ((uint8_t) acosf(v))
# define vector2d_cos(v) ((uint8_t) cosf(v))
#elif defined (_VECTOR2D_USE_INT8_)
# define vec_component int8_t
# define mod_vec_component vec_component
# define vector2d_pow(v, p) ((int8_t) powf(v, p))
# define vector2d_atan2(y, x) ((int8_t) atan2f(y, x))
# define vector2d_acos(v) ((int8_t) acosf(v))
# define vector2d_cos(v) ((int8_t) cosf(v))
#elif defined (_VECTOR2D_USE_UINT16_)
# define vec_component uint16_t
# define mod_vec_component vec_component
# define vector2d_pow(v, p) ((uint16_t) powf(v, p))
# define vector2d_atan2(y, x) ((uint16_t) atan2f(y, x))
# define vector2d_acos(v) ((uint16_t) acosf(v))
# define vector2d_cos(v) ((uint16_t) cosf(v))
#elif defined (_VECTOR2D_USE_INT16_)
# define vec_component int16_t
# define mod_vec_component vec_component
# define vector2d_pow(v, p) ((int16_t) powf(v, p))
# define vector2d_atan2(y, x) ((int16_t) atan2f(y, x))
# define vector2d_acos(v) ((int16_t) acosf(v))
# define vector2d_cos(v) ((int16_t) cosf(v))
#elif defined (_VECTOR2D_USE_UINT32_)
# define vec_component uint32_t
# define mod_vec_component vec_component
# define vector2d_pow(v, p) ((uint32_t) powf(v, p))
# define vector2d_atan2(y, x) ((uint32_t) atan2f(y, x))
# define vector2d_acos(v) ((uint32_t) acosf(v))
# define vector2d_cos(v) ((uint32_t) cosf(v))
#elif defined (_VECTOR2D_USE_INT32_)
# define vec_component int32_t
# define mod_vec_component vec_component
# define vector2d_pow(v, p) ((int32_t) powf(v, p))
# define vector2d_atan2(y, x) ((int32_t) atan2f(y, x))
# define vector2d_acos(v) ((int32_t) acosf(v))
# define vector2d_cos(v) ((int32_t) cosf(v))
#elif defined (_VECTOR2D_USE_UINT64_)
# define vec_component uint64_t
# define mod_vec_component vec_component
# define vector2d_pow(v, p) ((uint64_t) powl(v, p))
# define vector2d_atan2(y, x) ((uint64_t) atan2l(y, x))
# define vector2d_acos(v) ((uint64_t) acosl(v))
# define vector2d_cos(v) ((uint64_t) cosf(v))
#elif defined (_VECTOR2D_USE_INT64_)
# define vec_component int64_t
# define mod_vec_component vec_component
# define vector2d_pow(v, p) ((int64_t) powl(v, p))
# define vector2d_atan2(y, x) ((int64_t) atan2l(y, x))
# define vector2d_acos(v) ((int64_t) acosl(v))
# define vector2d_cos(v) ((int64_t) cosf(v))
#elif defined (_VECTOR2D_USE_DOUBLE_)
# define vec_component double
# define mod_vec_component int64_t
# define vector2d_pow(v, p) ((double) powl(v, p))
# define vector2d_atan2(y, x) ((double) atan2l(y, x))
# define vector2d_acos(v) ((double) acosl(v))
# define vector2d_cos(v) ((double) cosf(v))
#else
// default program flow
typedef float vec_component;
typedef int32_t mod_vec_component;
# define vector2d_pow(v, p) ((float) pow(v, p))
# define vector2d_atan2(y, x) ((float) atan2f(y, x))
# define vector2d_acos(v) ((float) acosf(v))
# define vector2d_cos(v) ((float) cosf(v))
# define vector2d_sin(v) ((float) sinf(v))
#endif

#define vector2d_sqrt(v) vector2d_pow(v, 0.5)
#define vector2d_abs(v) ((vec_component) vector2d_sqrt(vector2d_pow(v, 2)))

#endif // __VEC_COMPONENT_H_
Loading