2018-02-06 11:01:27 +00:00
|
|
|
// ascee_math.c
|
2018-01-29 15:14:50 +00:00
|
|
|
//
|
2018-02-06 11:01:27 +00:00
|
|
|
// Author: J.A. de Jong -ASCEE
|
2018-01-29 15:14:50 +00:00
|
|
|
//
|
|
|
|
// Description:
|
2018-02-06 11:01:27 +00:00
|
|
|
//
|
2018-01-29 15:14:50 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
#define TRACERPLUS (-10)
|
2018-02-06 11:01:27 +00:00
|
|
|
#include "ascee_math.h"
|
2018-01-29 15:14:50 +00:00
|
|
|
|
|
|
|
#include "ascee_assert.h"
|
|
|
|
#include "ascee_math.h"
|
2018-02-06 11:01:27 +00:00
|
|
|
#include "ascee_tracer.h"
|
2018-01-29 15:14:50 +00:00
|
|
|
|
|
|
|
#include <math.h>
|
|
|
|
|
|
|
|
#ifdef ASCEE_DEBUG
|
2018-02-06 11:01:27 +00:00
|
|
|
void print_dmat(const dmat* m) {
|
2018-02-09 10:56:49 +00:00
|
|
|
feTRACE(50);
|
2018-02-06 11:01:27 +00:00
|
|
|
size_t row,col;
|
|
|
|
for(row=0;row<m->n_rows;row++){
|
2018-02-09 10:56:49 +00:00
|
|
|
indent_trace();
|
2018-02-06 11:01:27 +00:00
|
|
|
for(col=0;col<m->n_cols;col++){
|
|
|
|
d val = *getdmatval(m,row,col);
|
|
|
|
printf("%c%2.2e ", val<0?'-':' ' ,d_abs(val));
|
|
|
|
|
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
|
|
|
|
}
|
2018-02-09 10:56:49 +00:00
|
|
|
fsTRACE(50);
|
2018-02-06 11:01:27 +00:00
|
|
|
}
|
2018-01-29 15:14:50 +00:00
|
|
|
void print_cmat(const cmat* m) {
|
2018-02-09 10:56:49 +00:00
|
|
|
feTRACE(50);
|
2018-01-29 15:14:50 +00:00
|
|
|
size_t row,col;
|
|
|
|
for(row=0;row<m->n_rows;row++){
|
2018-02-09 10:56:49 +00:00
|
|
|
indent_trace();
|
2018-01-29 15:14:50 +00:00
|
|
|
for(col=0;col<m->n_cols;col++){
|
2018-02-06 11:01:27 +00:00
|
|
|
c val = *getcmatval(m,row,col);
|
2018-01-29 15:14:50 +00:00
|
|
|
|
|
|
|
d rval = creal(val);
|
|
|
|
d ival = cimag(val);
|
|
|
|
|
2018-02-06 11:01:27 +00:00
|
|
|
printf("%c%2.2e%c%2.2ei ",rval< 0 ?'-': ' ',
|
|
|
|
d_abs(rval),ival<0 ? '-' : '+',d_abs(ival) ) ;
|
2018-01-29 15:14:50 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
|
|
|
|
}
|
2018-02-09 10:56:49 +00:00
|
|
|
feTRACE(50);
|
2018-01-29 15:14:50 +00:00
|
|
|
}
|
|
|
|
void print_vc(const vc* m) {
|
2018-02-09 10:56:49 +00:00
|
|
|
fsTRACE(50);
|
2018-01-29 15:14:50 +00:00
|
|
|
size_t row;
|
|
|
|
|
|
|
|
for(row=0;row<m->size;row++){
|
2018-02-09 10:56:49 +00:00
|
|
|
c val = *getvcval(m,row);
|
2018-01-29 15:14:50 +00:00
|
|
|
|
2018-02-09 10:56:49 +00:00
|
|
|
d rval = creal(val);
|
|
|
|
d ival = cimag(val);
|
|
|
|
indent_trace();
|
2018-01-29 15:14:50 +00:00
|
|
|
printf("%c%2.2e%c%2.2ei ",rval< 0 ?'-': ' ', d_abs(rval),ival<0 ? '-' : '+',d_abs(ival) ) ;
|
|
|
|
printf("\n");
|
|
|
|
|
|
|
|
}
|
2018-02-09 10:56:49 +00:00
|
|
|
feTRACE(50);
|
2018-01-29 15:14:50 +00:00
|
|
|
}
|
|
|
|
void print_vd(const vd* m) {
|
2018-02-09 10:56:49 +00:00
|
|
|
fsTRACE(50);
|
2018-01-29 15:14:50 +00:00
|
|
|
size_t row;
|
|
|
|
iVARTRACE(20,m->size);
|
|
|
|
for(row=0;row<m->size;row++){
|
|
|
|
|
2018-02-09 10:56:49 +00:00
|
|
|
d rval = m->ptr[row];
|
|
|
|
indent_trace();
|
2018-01-29 15:14:50 +00:00
|
|
|
printf("%c%2.2e ",rval< 0 ? '\r': ' ',rval);
|
|
|
|
printf("\n");
|
|
|
|
}
|
2018-02-09 10:56:49 +00:00
|
|
|
feTRACE(50);
|
2018-01-29 15:14:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|