NEURON
spdefs.h File Reference
#include <stdio.h>
#include <stdlib.h>

Go to the source code of this file.

Classes

struct  ComplexNumber
 
struct  MatrixElement
 
struct  AllocationRecord
 
struct  FillinListNodeStruct
 
struct  MatrixFrame
 

Macros

#define LINT   NO
 
#define BOOLEAN   int
 
#define NO   0
 
#define YES   1
 
#define NOT   !
 
#define AND   &&
 
#define OR   ||
 
#define NULL   0
 
#define SPARSE_ID   0x772773 /* Arbitrary (is Sparse on phone). */
 
#define IS_SPARSE(matrix)
 
#define IS_VALID(matrix)
 
#define IS_FACTORED(matrix)   ((matrix)->Factored && !(matrix)->NeedsOrdering)
 
#define MAX(a, b)   ((a) > (b) ? (a) : (b))
 
#define MIN(a, b)   ((a) < (b) ? (a) : (b))
 
#define ABS(a)   ((a) < 0.0 ? -(a) : (a))
 
#define SQR(a)   ((a)*(a))
 
#define SWAP(type, a, b)   {type swapx; swapx = a; a = b; b = swapx;}
 
#define ELEMENT_MAG(ptr)   ((ptr)->Real < 0.0 ? -(ptr)->Real : (ptr)->Real)
 
#define CMPLX_ASSIGN(to, from)
 
#define CMPLX_CONJ_ASSIGN(to, from)
 
#define CMPLX_NEGATE_ASSIGN(to, from)
 
#define CMPLX_CONJ_NEGATE_ASSIGN(to, from)
 
#define CMPLX_CONJ(a)   (a).Imag = -(a).Imag
 
#define CMPLX_NEGATE(a)
 
#define CMPLX_1_NORM(a)   (ABS((a).Real) + ABS((a).Imag))
 
#define CMPLX_INF_NORM(a)   (MAX (ABS((a).Real),ABS((a).Imag)))
 
#define CMPLX_2_NORM(a)   (sqrt((a).Real*(a).Real + (a).Imag*(a).Imag))
 
#define CMPLX_ADD(to, from_a, from_b)
 
#define CMPLX_SUBT(to, from_a, from_b)
 
#define CMPLX_ADD_ASSIGN(to, from)
 
#define CMPLX_SUBT_ASSIGN(to, from)
 
#define SCLR_MULT(to, sclr, cmplx)
 
#define SCLR_MULT_ASSIGN(to, sclr)
 
#define CMPLX_MULT(to, from_a, from_b)
 
#define CMPLX_MULT_ASSIGN(to, from)
 
#define CMPLX_CONJ_MULT(to, from_a, from_b)
 
#define CMPLX_MULT_ADD(to, mult_a, mult_b, add)
 
#define CMPLX_MULT_SUBT(to, mult_a, mult_b, subt)
 
#define CMPLX_CONJ_MULT_ADD(to, mult_a, mult_b, add)
 
#define CMPLX_MULT_ADD_ASSIGN(to, from_a, from_b)
 
#define CMPLX_MULT_SUBT_ASSIGN(to, from_a, from_b)
 
#define CMPLX_CONJ_MULT_ADD_ASSIGN(to, from_a, from_b)
 
#define CMPLX_CONJ_MULT_SUBT_ASSIGN(to, from_a, from_b)
 
#define CMPLX_DIV(to, num, den)
 
#define CMPLX_DIV_ASSIGN(num, den)
 
#define CMPLX_RECIPROCAL(to, den)
 
#define ASSERT(condition)
 
#define ABORT()
 
#define IMAG_VECTORS
 
#define IMAG_RHS
 
#define ALLOC(type, number)   ((type *)malloc((unsigned)(sizeof(type)*(number))))
 
#define REALLOC(ptr, type, number)    ptr = (type *)realloc((char *)ptr,(unsigned)(sizeof(type)*(number)))
 
#define FREE(ptr)   { if ((ptr) != NULL) {char* p = (char*)(ptr); (ptr) = NULL; free(p);} }
 
#define CALLOC(ptr, type, number)
 

Typedefs

typedef spREAL RealNumber
 
typedef spREALRealVector
 
typedef struct ComplexNumberComplexVector
 
typedef struct MatrixElementElementPtr
 
typedef ElementPtrArrayOfElementPtrs
 
typedef struct AllocationRecordAllocationListPtr
 
typedef struct MatrixFrameMatrixPtr
 

Macro Definition Documentation

◆ ABORT

#define ABORT ( )

Definition at line 395 of file spdefs.h.

◆ ABS

#define ABS (   a)    ((a) < 0.0 ? -(a) : (a))

Definition at line 134 of file spdefs.h.

◆ ALLOC

#define ALLOC (   type,
  number 
)    ((type *)malloc((unsigned)(sizeof(type)*(number))))

Definition at line 442 of file spdefs.h.

◆ AND

#define AND   &&

Definition at line 111 of file spdefs.h.

◆ ASSERT

#define ASSERT (   condition)

Definition at line 383 of file spdefs.h.

◆ BOOLEAN

#define BOOLEAN   int

Definition at line 107 of file spdefs.h.

◆ CALLOC

#define CALLOC (   ptr,
  type,
  number 
)
Value:
{ int i; ptr = ALLOC(type, number); \
if (ptr != (type *)NULL) \
for(i=(number)-1;i>=0; i--) ptr[i] = (type) 0; \
}
short type
Definition: cabvars.h:9
#define i
Definition: md1redef.h:12
#define NULL
Definition: spdefs.h:116
#define ALLOC(type, number)
Definition: spdefs.h:442

Definition at line 450 of file spdefs.h.

◆ CMPLX_1_NORM

#define CMPLX_1_NORM (   a)    (ABS((a).Real) + ABS((a).Imag))

Definition at line 173 of file spdefs.h.

◆ CMPLX_2_NORM

#define CMPLX_2_NORM (   a)    (sqrt((a).Real*(a).Real + (a).Imag*(a).Imag))

Definition at line 179 of file spdefs.h.

◆ CMPLX_ADD

#define CMPLX_ADD (   to,
  from_a,
  from_b 
)
Value:
{ (to).Real = (from_a).Real + (from_b).Real; \
(to).Imag = (from_a).Imag + (from_b).Imag; \
}
#define Real
Definition: machine.h:189

Definition at line 182 of file spdefs.h.

◆ CMPLX_ADD_ASSIGN

#define CMPLX_ADD_ASSIGN (   to,
  from 
)
Value:
{ (to).Real += (from).Real; \
(to).Imag += (from).Imag; \
}

Definition at line 194 of file spdefs.h.

◆ CMPLX_ASSIGN

#define CMPLX_ASSIGN (   to,
  from 
)
Value:
{ (to).Real = (from).Real; \
(to).Imag = (from).Imag; \
}

Definition at line 150 of file spdefs.h.

◆ CMPLX_CONJ

#define CMPLX_CONJ (   a)    (a).Imag = -(a).Imag

Definition at line 166 of file spdefs.h.

◆ CMPLX_CONJ_ASSIGN

#define CMPLX_CONJ_ASSIGN (   to,
  from 
)
Value:
{ (to).Real = (from).Real; \
(to).Imag = -(from).Imag; \
}

Definition at line 154 of file spdefs.h.

◆ CMPLX_CONJ_MULT

#define CMPLX_CONJ_MULT (   to,
  from_a,
  from_b 
)
Value:
{ (to).Real = (from_a).Real * (from_b).Real + \
(from_a).Imag * (from_b).Imag; \
(to).Imag = (from_a).Real * (from_b).Imag - \
(from_a).Imag * (from_b).Real; \
}

Definition at line 236 of file spdefs.h.

◆ CMPLX_CONJ_MULT_ADD

#define CMPLX_CONJ_MULT_ADD (   to,
  mult_a,
  mult_b,
  add 
)
Value:
{ (to).Real = (mult_a).Real * (mult_b).Real + \
(mult_a).Imag * (mult_b).Imag + (add).Real; \
(to).Imag = (mult_a).Real * (mult_b).Imag - \
(mult_a).Imag * (mult_b).Real + (add).Imag; \
}
#define add
Definition: redef.h:24

Definition at line 264 of file spdefs.h.

◆ CMPLX_CONJ_MULT_ADD_ASSIGN

#define CMPLX_CONJ_MULT_ADD_ASSIGN (   to,
  from_a,
  from_b 
)
Value:
{ (to).Real += (from_a).Real * (from_b).Real + \
(from_a).Imag * (from_b).Imag; \
(to).Imag += (from_a).Real * (from_b).Imag - \
(from_a).Imag * (from_b).Real; \
}

Definition at line 292 of file spdefs.h.

◆ CMPLX_CONJ_MULT_SUBT_ASSIGN

#define CMPLX_CONJ_MULT_SUBT_ASSIGN (   to,
  from_a,
  from_b 
)
Value:
{ (to).Real -= (from_a).Real * (from_b).Real + \
(from_a).Imag * (from_b).Imag; \
(to).Imag -= (from_a).Real * (from_b).Imag - \
(from_a).Imag * (from_b).Real; \
}

Definition at line 302 of file spdefs.h.

◆ CMPLX_CONJ_NEGATE_ASSIGN

#define CMPLX_CONJ_NEGATE_ASSIGN (   to,
  from 
)
Value:
{ (to).Real = -(from).Real; \
(to).Imag = (from).Imag; \
}

Definition at line 162 of file spdefs.h.

◆ CMPLX_DIV

#define CMPLX_DIV (   to,
  num,
  den 
)
Value:
{ RealNumber r_, s_; \
if (((den).Real >= (den).Imag AND (den).Real > -(den).Imag) OR \
((den).Real < (den).Imag AND (den).Real <= -(den).Imag)) \
{ r_ = (den).Imag / (den).Real; \
s_ = (den).Real + r_*(den).Imag; \
(to).Real = ((num).Real + r_*(num).Imag)/s_; \
(to).Imag = ((num).Imag - r_*(num).Real)/s_; \
} \
else \
{ r_ = (den).Real / (den).Imag; \
s_ = (den).Imag + r_*(den).Real; \
(to).Real = (r_*(num).Real + (num).Imag)/s_; \
(to).Imag = (r_*(num).Imag - (num).Real)/s_; \
} \
}
#define OR
Definition: spdefs.h:112
spREAL RealNumber
Definition: spdefs.h:468
#define AND
Definition: spdefs.h:111

Definition at line 314 of file spdefs.h.

◆ CMPLX_DIV_ASSIGN

#define CMPLX_DIV_ASSIGN (   num,
  den 
)
Value:
{ RealNumber r_, s_, t_; \
if (((den).Real >= (den).Imag AND (den).Real > -(den).Imag) OR \
((den).Real < (den).Imag AND (den).Real <= -(den).Imag)) \
{ r_ = (den).Imag / (den).Real; \
s_ = (den).Real + r_*(den).Imag; \
t_ = ((num).Real + r_*(num).Imag)/s_; \
(num).Imag = ((num).Imag - r_*(num).Real)/s_; \
(num).Real = t_; \
} \
else \
{ r_ = (den).Real / (den).Imag; \
s_ = (den).Imag + r_*(den).Real; \
t_ = (r_*(num).Real + (num).Imag)/s_; \
(num).Imag = (r_*(num).Imag - (num).Real)/s_; \
(num).Real = t_; \
} \
}

Definition at line 332 of file spdefs.h.

◆ CMPLX_INF_NORM

#define CMPLX_INF_NORM (   a)    (MAX (ABS((a).Real),ABS((a).Imag)))

Definition at line 176 of file spdefs.h.

◆ CMPLX_MULT

#define CMPLX_MULT (   to,
  from_a,
  from_b 
)
Value:
{ (to).Real = (from_a).Real * (from_b).Real - \
(from_a).Imag * (from_b).Imag; \
(to).Imag = (from_a).Real * (from_b).Imag + \
(from_a).Imag * (from_b).Real; \
}

Definition at line 218 of file spdefs.h.

◆ CMPLX_MULT_ADD

#define CMPLX_MULT_ADD (   to,
  mult_a,
  mult_b,
  add 
)
Value:
{ (to).Real = (mult_a).Real * (mult_b).Real - \
(mult_a).Imag * (mult_b).Imag + (add).Real; \
(to).Imag = (mult_a).Real * (mult_b).Imag + \
(mult_a).Imag * (mult_b).Real + (add).Imag; \
}

Definition at line 245 of file spdefs.h.

◆ CMPLX_MULT_ADD_ASSIGN

#define CMPLX_MULT_ADD_ASSIGN (   to,
  from_a,
  from_b 
)
Value:
{ (to).Real += (from_a).Real * (from_b).Real - \
(from_a).Imag * (from_b).Imag; \
(to).Imag += (from_a).Real * (from_b).Imag + \
(from_a).Imag * (from_b).Real; \
}

Definition at line 273 of file spdefs.h.

◆ CMPLX_MULT_ASSIGN

#define CMPLX_MULT_ASSIGN (   to,
  from 
)
Value:
{ RealNumber to_real_ = (to).Real; \
(to).Real = to_real_ * (from).Real - \
(to).Imag * (from).Imag; \
(to).Imag = to_real_ * (from).Imag + \
(to).Imag * (from).Real; \
}

Definition at line 226 of file spdefs.h.

◆ CMPLX_MULT_SUBT

#define CMPLX_MULT_SUBT (   to,
  mult_a,
  mult_b,
  subt 
)
Value:
{ (to).Real = (subt).Real - (mult_a).Real * (mult_b).Real + \
(mult_a).Imag * (mult_b).Imag; \
(to).Imag = (subt).Imag - (mult_a).Real * (mult_b).Imag - \
(mult_a).Imag * (mult_b).Real; \
}

Definition at line 254 of file spdefs.h.

◆ CMPLX_MULT_SUBT_ASSIGN

#define CMPLX_MULT_SUBT_ASSIGN (   to,
  from_a,
  from_b 
)
Value:
{ (to).Real -= (from_a).Real * (from_b).Real - \
(from_a).Imag * (from_b).Imag; \
(to).Imag -= (from_a).Real * (from_b).Imag + \
(from_a).Imag * (from_b).Real; \
}

Definition at line 282 of file spdefs.h.

◆ CMPLX_NEGATE

#define CMPLX_NEGATE (   a)
Value:
{ (a).Real = -(a).Real; \
(a).Imag = -(a).Imag; \
}

Definition at line 167 of file spdefs.h.

◆ CMPLX_NEGATE_ASSIGN

#define CMPLX_NEGATE_ASSIGN (   to,
  from 
)
Value:
{ (to).Real = -(from).Real; \
(to).Imag = -(from).Imag; \
}

Definition at line 158 of file spdefs.h.

◆ CMPLX_RECIPROCAL

#define CMPLX_RECIPROCAL (   to,
  den 
)
Value:
{ RealNumber r_; \
if (((den).Real >= (den).Imag AND (den).Real > -(den).Imag) OR \
((den).Real < (den).Imag AND (den).Real <= -(den).Imag)) \
{ r_ = (den).Imag / (den).Real; \
(to).Imag = -r_*((to).Real = 1.0/((den).Real + r_*(den).Imag)); \
} \
else \
{ r_ = (den).Real / (den).Imag; \
(to).Real = -r_*((to).Imag = -1.0/((den).Imag + r_*(den).Real));\
} \
}

Definition at line 352 of file spdefs.h.

◆ CMPLX_SUBT

#define CMPLX_SUBT (   to,
  from_a,
  from_b 
)
Value:
{ (to).Real = (from_a).Real - (from_b).Real; \
(to).Imag = (from_a).Imag - (from_b).Imag; \
}

Definition at line 188 of file spdefs.h.

◆ CMPLX_SUBT_ASSIGN

#define CMPLX_SUBT_ASSIGN (   to,
  from 
)
Value:
{ (to).Real -= (from).Real; \
(to).Imag -= (from).Imag; \
}

Definition at line 200 of file spdefs.h.

◆ ELEMENT_MAG

#define ELEMENT_MAG (   ptr)    ((ptr)->Real < 0.0 ? -(ptr)->Real : (ptr)->Real)

Definition at line 146 of file spdefs.h.

◆ FREE

#define FREE (   ptr)    { if ((ptr) != NULL) {char* p = (char*)(ptr); (ptr) = NULL; free(p);} }

Definition at line 446 of file spdefs.h.

◆ IMAG_RHS

#define IMAG_RHS

Definition at line 415 of file spdefs.h.

◆ IMAG_VECTORS

RealVector Solution IMAG_VECTORS

Definition at line 414 of file spdefs.h.

◆ IS_FACTORED

#define IS_FACTORED (   matrix)    ((matrix)->Factored && !(matrix)->NeedsOrdering)

Definition at line 126 of file spdefs.h.

◆ IS_SPARSE

#define IS_SPARSE (   matrix)
Value:
((matrix) != NULL && \
(matrix)->ID == SPARSE_ID)
#define SPARSE_ID
Definition: spdefs.h:119

Definition at line 120 of file spdefs.h.

◆ IS_VALID

#define IS_VALID (   matrix)
Value:
((matrix) != NULL && \
(matrix)->ID == SPARSE_ID && \
(matrix)->Error >= spOKAY && \
(matrix)->Error < spFATAL)
#define spFATAL
Definition: spmatrix.h:104
#define spOKAY
Definition: spmatrix.h:97

Definition at line 122 of file spdefs.h.

◆ LINT

#define LINT   NO

Definition at line 86 of file spdefs.h.

◆ MAX

#define MAX (   a,
 
)    ((a) > (b) ? (a) : (b))

Definition at line 130 of file spdefs.h.

◆ MIN

#define MIN (   a,
 
)    ((a) < (b) ? (a) : (b))

Definition at line 131 of file spdefs.h.

◆ NO

#define NO   0

Definition at line 108 of file spdefs.h.

◆ NOT

#define NOT   !

Definition at line 110 of file spdefs.h.

◆ NULL

#define NULL   0

Definition at line 116 of file spdefs.h.

◆ OR

#define OR   ||

Definition at line 112 of file spdefs.h.

◆ REALLOC

#define REALLOC (   ptr,
  type,
  number 
)     ptr = (type *)realloc((char *)ptr,(unsigned)(sizeof(type)*(number)))

Definition at line 443 of file spdefs.h.

◆ SCLR_MULT

#define SCLR_MULT (   to,
  sclr,
  cmplx 
)
Value:
{ (to).Real = (sclr) * (cmplx).Real; \
(to).Imag = (sclr) * (cmplx).Imag; \
}

Definition at line 206 of file spdefs.h.

◆ SCLR_MULT_ASSIGN

#define SCLR_MULT_ASSIGN (   to,
  sclr 
)
Value:
{ (to).Real *= (sclr); \
(to).Imag *= (sclr); \
}

Definition at line 212 of file spdefs.h.

◆ SPARSE_ID

#define SPARSE_ID   0x772773 /* Arbitrary (is Sparse on phone). */

Definition at line 119 of file spdefs.h.

◆ SQR

#define SQR (   a)    ((a)*(a))

Definition at line 137 of file spdefs.h.

◆ SWAP

#define SWAP (   type,
  a,
 
)    {type swapx; swapx = a; a = b; b = swapx;}

Definition at line 140 of file spdefs.h.

◆ YES

#define YES   1

Definition at line 109 of file spdefs.h.

Typedef Documentation

◆ AllocationListPtr

Definition at line 594 of file spdefs.h.

◆ ArrayOfElementPtrs

Definition at line 563 of file spdefs.h.

◆ ComplexVector

typedef struct ComplexNumber * ComplexVector

◆ ElementPtr

typedef struct MatrixElement* ElementPtr

Definition at line 562 of file spdefs.h.

◆ MatrixPtr

typedef struct MatrixFrame* MatrixPtr

Definition at line 880 of file spdefs.h.

◆ RealNumber

typedef spREAL RealNumber

Definition at line 468 of file spdefs.h.

◆ RealVector

typedef spREAL * RealVector

Definition at line 468 of file spdefs.h.