Skip to content

Commit

Permalink
final
Browse files Browse the repository at this point in the history
  • Loading branch information
Kate-Tol3 committed Apr 22, 2024
1 parent ad12345 commit af50186
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 23 deletions.
Binary file modified a.exe
Binary file not shown.
1 change: 0 additions & 1 deletion complex.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ void complex_get_number(void* ptr){
scanf("%lf", &(((Complex*)ptr)->img));
}


static FieldInfo* COMPLEX_FIELD_INFO= NULL;

FieldInfo* get_info_complex(){
Expand Down
2 changes: 1 addition & 1 deletion matrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ void read_matrix (Matrix* mat){
}


// matrix operation fumctions
// matrix operation functions
void sum_matrix (const Matrix* mat1, const Matrix* mat2, Matrix* res){
// if (match_matrix_types(mat1, mat2)&& match_matrix_types(mat2, res) && \
// match_matrix_size(mat1, mat2) && match_matrix_size(mat2, res)){
Expand Down
7 changes: 6 additions & 1 deletion matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,27 @@ typedef struct {

} Matrix;


//make_new_matrix
Matrix* new_matrix(const size_t, const size_t, FieldInfo*);

//elemet setter and getter
void get_element(const Matrix*,const size_t,const size_t, void*);
void* get_element_pointer(const Matrix*,const size_t,const size_t);
void set_element(Matrix*,const size_t i,const size_t j, const void* val);

// compare functions
int match_matrix_types(const Matrix*, const Matrix* );
int match_matrix_size(const Matrix*, const Matrix* );
int match_matrix_size_opposite(const Matrix*, const Matrix* );


// matrix making and printing functions
void fill_matrix(Matrix*, const void*);
void fill_zeros_matrix(Matrix*);
void print_matrix(Matrix*);
void read_matrix(Matrix*);

// matrix operation functions
void sum_matrix (const Matrix* , const Matrix*, Matrix*);
void transpose_matrix(const Matrix*, Matrix*);
void mult_matrix(Matrix*, Matrix*, Matrix*);
Expand Down
3 changes: 0 additions & 3 deletions real.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ void real_mult(const void* v1,const void* v2, void* res){
memcpy(res, &val, sizeof(double));
}


void real_print(const void* el){
printf("%.3lf", *((const double*) el));
}
Expand All @@ -34,8 +33,6 @@ void read_real_array(const size_t v,const size_t h, void* elems){
}
}

//static void* REAL_ZERO = NULL;

void real_set_zero(void* ptr){
*(double*)ptr = 0.0;
}
Expand Down
15 changes: 10 additions & 5 deletions test.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@

#define FLT_EPSILON 1.19209e-07

// TESTING TYPES
/// Testing types

//int
void test_int_sum() {
int v1 = 15;
int v2 = -200;
Expand Down Expand Up @@ -44,6 +45,7 @@ void test_int_mult() {
free(result);
}

//real
void test_real_sum() {
double v1 = 7.6;
double v2 = -100.4;
Expand Down Expand Up @@ -79,6 +81,7 @@ void test_real_mult() {
free(result);
}

//complex
void test_complex_sum() {
Complex v1 = {-1000.4628, 568.2478};
Complex v2 = {329.47843, -2164.0475};
Expand Down Expand Up @@ -110,6 +113,7 @@ void test_complex_mult() {
free(result);
}

//funtions to start testing
void test_int_functions(){
test_int_sum();
test_int_mult();
Expand All @@ -128,6 +132,7 @@ void test_complex_functions(){

/// Testing matrix functions

//sum_matrix
void test_sum_matrix_int(){
//int
FieldInfo* info = get_info_int();
Expand Down Expand Up @@ -220,7 +225,7 @@ void test_sum_matrix_complex(){
free(result);
}


//mult_matrix
void test_mult_matrix_int(){
//int
FieldInfo* info = get_info_int();
Expand Down Expand Up @@ -309,7 +314,7 @@ void test_mult_matrix_complex(){
free(result);
}


//mult_on_number_matrix
void test_mult_on_number_matrix_int(){
//int
FieldInfo* info = get_info_int();
Expand Down Expand Up @@ -390,7 +395,7 @@ void test_mult_on_number_matrix_complex(){
free(result);
}


//transpose_matrix
void test_transpose_matrix_int(){
//int
FieldInfo* info = get_info_int();
Expand Down Expand Up @@ -476,7 +481,7 @@ void test_transpose_matrix_complex(){
free(result);
}


//functions to start testing
void test_sum_matrix(){
test_sum_matrix_int();
test_sum_matrix_real();
Expand Down
1 change: 1 addition & 0 deletions test.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#pragma once
///Functions to start testing

void test_int_functions();
void test_real_functions();
Expand Down
13 changes: 1 addition & 12 deletions types_func.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,14 @@

void int_sum(const void* v1,const void* v2, void* res);
void int_mult(const void* v1,const void* v2, void* res);
void int_print(void* el);
void read_int_array(const size_t v,const size_t h, void* elems);
void int_set_zero(void* ptr);
void int_get_number(void* ptr);

//float functions

void real_sum(const void* v1,const void* v2, void* res);
void real_mult(const void* v1,const void* v2, void* res);
void real_print(void* el);
void read_real_array(const size_t v,const size_t h, void* elems);
void real_set_zero(void* ptr);
void real_get_number(void* ptr);

//complex functions

void complex_sum(const void* v1,const void* v2, void* res);
void complex_mult(const void* v1,const void* v2, void* res);
void complex_print(void* el);
void read_complex_array(const size_t v,const size_t h, void* elems);
void complex_set_zero(void* ptr);
void complex_get_number(void* ptr);

0 comments on commit af50186

Please sign in to comment.