Add function atanh to .control section

This commit is contained in:
Holger Vogt 2023-03-15 16:06:58 +01:00
parent 3996d27b29
commit 71571a1432
4 changed files with 35 additions and 0 deletions

View File

@ -343,6 +343,7 @@ struct func ft_funcs[] = {
{ "cosh", cx_cosh },
{ "tanh", cx_tanh },
{ "atan", cx_atan },
{ "atanh", cx_atanh },
{ "sortorder", cx_sortorder },
{ "norm", cx_norm },
{ "rnd", cx_rnd },

View File

@ -74,6 +74,7 @@ extern void *cx_cosh(void *, short int , int , int *, short int *);
extern void *cx_tan(void *, short int , int , int *, short int *);
extern void *cx_tanh(void *, short int , int , int *, short int *);
extern void *cx_atan(void *, short int , int , int *, short int *);
extern void *cx_atanh(void*, short int, int, int*, short int*);
extern void *cx_floor(void *, short int , int , int *, short int *);
extern void *cx_ceil(void *, short int , int , int *, short int *);
extern void *cx_nint(void *, short int , int , int *, short int *);

View File

@ -21,6 +21,7 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group
#include <errno.h>
#include <complex.h>
#include "ngspice/ngspice.h"
#include "ngspice/memory.h"
@ -862,6 +863,37 @@ cx_tanh(void *data, short int type, int length, int *newlength, short int *newty
}
}
/** atanh of a complex vector: use C99 function catanh. */
void*
cx_atanh(void* data, short int type, int length, int* newlength, short int* newtype)
{
if (type == VF_COMPLEX) {
ngcomplex_t* d = alloc_c(length);
*newtype = VF_COMPLEX;
*newlength = length;
ngcomplex_t* cc = (ngcomplex_t*)data;
int i;
for (i = 0; i < length; i++) {
_Dcomplex midin = _Cbuild(cc->cx_real, cc->cx_imag);
_Dcomplex midout = catanh(midin);
d[i].cx_real = creal(midout);
d[i].cx_imag = cimag(midout);
}
return ((void*)d);
}
else {
double* d = alloc_d(length);
*newtype = VF_REAL;
*newlength = length;
double* cc = (double*)data;
int i;
for (i = 0; i < length; i++) {
d[i] = atanh(cc[i]);
}
return ((void*)d);
}
}
/** atan of a complex vector: return atan of the real part. */
void *
cx_atan(void *data, short int type, int length, int *newlength, short int *newtype)

View File

@ -32,6 +32,7 @@ void * cx_cosh(void *data, short int type, int length, int *newlength, short int
void * cx_tan(void *data, short int type, int length, int *newlength, short int *newtype);
void * cx_tanh(void *data, short int type, int length, int *newlength, short int *newtype);
void * cx_atan(void *data, short int type, int length, int *newlength, short int *newtype);
void * cx_atanh(void *data, short int type, int length, int *newlength, short int *newtype);
void * cx_sortorder(void *data, short int type, int length, int *newlength, short int *newtype);