taucs.h
来自「finite element mesh 参数化有限元网格划分」· C头文件 代码 · 共 852 行 · 第 1/2 页
H
852 行
#ifndef TAUCS_H
#define TAUCS_H
/*********************************************************/
/* TAUCS */
/* Author: Sivan Toledo */
/*********************************************************/
#include "taucs_config_tests.h"
#include "taucs_config_build.h"
#include <complex>
#include <stdlib.h>
#include <float.h>
#ifdef __cplusplus
extern "C" {
#endif
/*********************************************************/
/* Cilk-related stuff */
/*********************************************************/
#ifdef TAUCS_CILK
#undef TAUCS_C99_COMPLEX /* cilk2c can't process complex.h */
#endif
#ifdef TAUCS_CORE_CILK
#ifdef TAUCS_CILK
/* We are compiling a Cilk source with a Cilk compiler */
#include <cilk.h>
#include <cilk-lib.h>
#define taucs_cilk cilk
#define taucs_spawn spawn
#define taucs_sync sync
#define taucs_inlet inlet
#define taucs_Self Self
#define taucs_Cilk_active_size Cilk_active_size
#else
/* We are compiling a Cilk source, but with a C compiler */
#define cilk
#define spawn
#define sync
#define inlet
#define Self 0
#define Cilk_active_size 1
#define taucs_cilk
#define taucs_spawn
#define taucs_sync
#define taucs_inlet
#define taucs_Self 0
#define taucs_Cilk_active_size 1
#endif
#else /* not CORE_CILK */
#define taucs_cilk
#define taucs_spawn
#define taucs_sync
#define taucs_inlet
#define taucs_Self 0
#define taucs_Cilk_active_size 1
#endif
/*********************************************************/
/* other stuff */
/*********************************************************/
#ifdef TAUCS_CONFIG_DREAL
#define TAUCS_DOUBLE_IN_BUILD
#endif
#ifdef TAUCS_CONFIG_SREAL
#define TAUCS_SINGLE_IN_BUILD
#endif
#ifdef TAUCS_CONFIG_DCOMPLEX
#define TAUCS_DCOMPLEX_IN_BUILD
#endif
#ifdef TAUCS_CONFIG_SCOMPLEX
#define TAUCS_SCOMPLEX_IN_BUILD
#endif
#if defined(TAUCS_BLAS_UNDERSCORE)
#define taucs_blas_name(x) (x##_)
#elif defined(TAUCS_BLAS_NOUNDERSCORE)
#define taucs_blas_name(x) (x)
#else
#error "taucs_blas_[no]underscore_test: linking with the BLAS failed both attempts"
#endif
#ifdef OSTYPE_win32
typedef unsigned long ssize_t;
typedef int mode_t;
typedef int perm_t;
#define random rand
#define srandom srand
#endif
#define TAUCS_SUCCESS 0
#define TAUCS_ERROR -1
#define TAUCS_ERROR_NOMEM -2
#define TAUCS_ERROR_BADARGS -3
#define TAUCS_ERROR_INDEFINITE -4
#define TAUCS_ERROR_MAXDEPTH -5
#define TAUCS_INT 1024
#define TAUCS_DOUBLE 2048
#define TAUCS_SINGLE 4096
#define TAUCS_DCOMPLEX 8192
#define TAUCS_SCOMPLEX 16384
#define TAUCS_LOWER 1
#define TAUCS_UPPER 2
#define TAUCS_TRIANGULAR 4
#define TAUCS_SYMMETRIC 8
#define TAUCS_HERMITIAN 16
#define TAUCS_PATTERN 32
#define TAUCS_METHOD_LLT 1
#define TAUCS_METHOD_LDLT 2
#define TAUCS_METHOD_PLU 3
#define TAUCS_VARIANT_SNMF 1
#define TAUCS_VARIANT_SNLL 2
typedef double taucs_double;
typedef float taucs_single;
/* The macro TAUCS_C99_COMPLEX is defined in */
/* build/OSTYPE/taucs_config_tests if the */
/* test program progs/taucs_c99_complex_test */
/* compiles, links, and runs. */
/*#if defined(__GNUC__) && !defined(TAUCS_CONFIG_GENERIC_COMPLEX)*/
#ifdef TAUCS_C99_COMPLEX
/*
typedef __complex__ double taucs_dcomplex;
typedef __complex__ float taucs_scomplex;
*/
#undef I
#ifdef _Imaginary_I
#define TAUCS_IMAGINARY_I _Imaginary_I
#else
#define TAUCS_IMAGINARY_I _Complex_I
#endif
typedef _Complex double taucs_dcomplex;
typedef _Complex float taucs_scomplex;
#define taucs_complex_create(r,i) ((r)+TAUCS_IMAGINARY_I*(i))
#define taucs_ccomplex_create(r,i) ((r)+TAUCS_IMAGINARY_I*(i))
#define taucs_zcomplex_create(r,i) ((r)+TAUCS_IMAGINARY_I*(i))
#define taucs_add(x,y) ((x)+(y))
#define taucs_sub(x,y) ((x)-(y))
#define taucs_mul(x,y) ((x)*(y))
#define taucs_div(x,y) ((x)/(y))
#define taucs_neg(x) (-(x))
#define taucs_dadd(x,y) ((x)+(y))
#define taucs_dsub(x,y) ((x)-(y))
#define taucs_dmul(x,y) ((x)*(y))
#define taucs_ddiv(x,y) ((x)/(y))
#define taucs_dneg(x) (-(x))
#define taucs_dconj(x) (x)
#define taucs_dimag(x) 0.0
#define taucs_dreal(x) (x)
#define taucs_dminusone -1.0
#define taucs_done 1.0
#define taucs_dzero 0.0
#define taucs_dabs(x) (fabs(x))
#define taucs_dsqrt(x) (sqrt(x))
#define taucs_sadd(x,y) ((x)+(y))
#define taucs_ssub(x,y) ((x)-(y))
#define taucs_smul(x,y) ((x)*(y))
#define taucs_sdiv(x,y) ((x)/(y))
#define taucs_sneg(x) (-(x))
#define taucs_sconj(x) (x)
#define taucs_simag(x) 0.0f
#define taucs_sreal(x) (x)
#define taucs_sminusone -1.0f
#define taucs_sone 1.0f
#define taucs_szero 0.0f
#define taucs_sabs(x) ((taucs_single) fabs(x))
#define taucs_ssqrt(x) ((taucs_single) sqrt(x))
#define taucs_zadd(x,y) ((x)+(y))
#define taucs_zsub(x,y) ((x)-(y))
#define taucs_zmul(x,y) ((x)*(y))
#define taucs_zdiv(x,y) ((x)/(y))
#define taucs_zneg(x) (-(x))
#define taucs_zconj(x) (conj(x))
#define taucs_zimag(x) (cimag(x))
#define taucs_zreal(x) (creal(x))
#define taucs_zminusone -1.0+0.0*TAUCS_IMAGINARY_I
#define taucs_zone 1.0+0.0*TAUCS_IMAGINARY_I
#define taucs_zzero 0.0+0.0*TAUCS_IMAGINARY_I
#define taucs_zabs(x) (cabs(x))
#define taucs_zsqrt(x) (csqrt(x))
#define taucs_cadd(x,y) ((x)+(y))
#define taucs_csub(x,y) ((x)-(y))
#define taucs_cmul(x,y) ((x)*(y))
#define taucs_cdiv(x,y) ((x)/(y))
#define taucs_cneg(x) (-(x))
#define taucs_cconj(x) (conjf(x))
#define taucs_cimag(x) (cimagf(x))
#define taucs_creal(x) (crealf(x))
#define taucs_cminusone -1.0f+0.0f*TAUCS_IMAGINARY_I
#define taucs_cone 1.0f+0.0f*TAUCS_IMAGINARY_I
#define taucs_czero 0.0f+0.0f*TAUCS_IMAGINARY_I
#define taucs_cabs(x) (cabsf(x))
#define taucs_csqrt(x) (csqrt(x))
#if defined(TAUCS_CORE_DOUBLE)
#define taucs_conj(x) (x)
#define taucs_im(x) 0.0
#define taucs_re(x) (x)
#define taucs_minusone -1.0
#define taucs_one 1.0
#define taucs_zero 0.0
#define taucs_abs(x) (fabs(x))
#define taucs_sqrt(x) (sqrt(x))
#elif defined(TAUCS_CORE_GENERAL)
#define taucs_im(x) 0.0
#define taucs_re(x) (x)
#define taucs_minusone -1.0
#define taucs_one 1.0
#define taucs_zero 0.0
/*
#define taucs_conj(x) (x)
#define taucs_abs(x) (fabs(x))
#define taucs_sqrt(x) (sqrt(x))
*/
#elif defined(TAUCS_CORE_SINGLE)
#define taucs_conj(x) (x)
#define taucs_im(x) 0.0f
#define taucs_re(x) (x)
#define taucs_minusone -1.0f
#define taucs_one 1.0f
#define taucs_zero 0.0f
#define taucs_abs(x) ((taucs_single) fabs(x))
#define taucs_sqrt(x) ((taucs_single) sqrt(x))
#elif defined(TAUCS_CORE_DCOMPLEX)
/*
#define taucs_conj(x) (~(x))
#define taucs_im(x) (__imag__ (x))
#define taucs_re(x) (__real__ (x))
#define taucs_minusone -1.0+0.0i
#define taucs_one 1.0+0.0i
#define taucs_zero 0.0+0.0i
#define taucs_abs(x) taucs_zabs_fn(x)
#define taucs_sqrt(x) taucs_zsqrt_fn(x)
*/
#define taucs_conj(x) (conj(x))
#define taucs_im(x) (cimag(x))
#define taucs_re(x) (creal(x))
#define taucs_minusone -1.0+0.0*TAUCS_IMAGINARY_I
#define taucs_one 1.0+0.0*TAUCS_IMAGINARY_I
#define taucs_zero 0.0+0.0*TAUCS_IMAGINARY_I
#define taucs_abs(x) (cabs(x))
#define taucs_sqrt(x) (csqrt(x))
#elif defined(TAUCS_CORE_SCOMPLEX)
/*
#define taucs_conj(x) (~(x))
#define taucs_im(x) (__imag__ (x))
#define taucs_re(x) (__real__ (x))
#define taucs_minusone -1.0f+0.0fi
#define taucs_one 1.0f+0.0fi
#define taucs_zero 0.0f+0.0fi
#define taucs_abs(x) taucs_cabs_fn(x)
#define taucs_sqrt(x) taucs_csqrt_fn(x)
*/
#define taucs_conj(x) (conjf(x))
#define taucs_im(x) (cimagf(x))
#define taucs_re(x) (crealf(x))
#define taucs_minusone -1.0f+0.0f*TAUCS_IMAGINARY_I
#define taucs_one 1.0f+0.0f*TAUCS_IMAGINARY_I
#define taucs_zero 0.0f+0.0f*TAUCS_IMAGINARY_I
#define taucs_abs(x) (cabsf(x))
#define taucs_sqrt(x) (csqrtf(x))
#endif
#else /* C99 */
typedef struct {double r,i;} taucs_dcomplex;
typedef struct {float r,i;} taucs_scomplex;
#define taucs_zcomplex_create(r,i) taucs_zcomplex_create_fn(r,i)
#define taucs_ccomplex_create(r,i) taucs_ccomplex_create_fn(r,i)
#define taucs_dadd(x,y) ((x)+(y))
#define taucs_dsub(x,y) ((x)-(y))
#define taucs_dmul(x,y) ((x)*(y))
#define taucs_ddiv(x,y) ((x)/(y))
#define taucs_dneg(x) (-(x))
#define taucs_dconj(x) (x)
#define taucs_dabs(x) (fabs(x))
#define taucs_dsqrt(x) (sqrt(x))
#define taucs_dimag(x) 0.0
#define taucs_dreal(x) (x)
#define taucs_dminusone -1.0
#define taucs_done 1.0
#define taucs_dzero 0.0
#define taucs_sadd(x,y) ((x)+(y))
#define taucs_ssub(x,y) ((x)-(y))
#define taucs_smul(x,y) ((x)*(y))
#define taucs_sdiv(x,y) ((x)/(y))
#define taucs_sneg(x) (-(x))
#define taucs_sconj(x) (x)
#define taucs_sabs(x) ((taucs_single) fabs(x))
#define taucs_ssqrt(x) ((taucs_single) sqrt(x))
#define taucs_sim(x) 0.0f
#define taucs_sre(x) (x)
#define taucs_sminusone -1.0f
#define taucs_sone 1.0f
#define taucs_szero 0.0f
#define taucs_zadd(x,y) taucs_zadd_fn(x,y)
#define taucs_zsub(x,y) taucs_zsub_fn(x,y)
#define taucs_zmul(x,y) taucs_zmul_fn(x,y)
#define taucs_zdiv(x,y) taucs_zdiv_fn(x,y)
#define taucs_zneg(x) taucs_zneg_fn(x)
#define taucs_zconj(x) taucs_zconj_fn(x)
#define taucs_zabs(x) taucs_zabs_fn(x)
#define taucs_zsqrt(x) taucs_zsqrt_fn(x)
#define taucs_zimag(x) ((x).i)
#define taucs_zreal(x) ((x).r)
#define taucs_zminusone taucs_zminusone_const
#define taucs_zone taucs_zone_const
#define taucs_zzero taucs_zzero_const
#define taucs_cadd(x,y) taucs_cadd_fn(x,y)
#define taucs_csub(x,y) taucs_csub_fn(x,y)
#define taucs_cmul(x,y) taucs_cmul_fn(x,y)
#define taucs_cdiv(x,y) taucs_cdiv_fn(x,y)
#define taucs_cneg(x) taucs_cneg_fn(x)
#define taucs_cconj(x) taucs_cconj_fn(x)
#define taucs_cabs(x) taucs_cabs_fn(x)
#define taucs_csqrt(x) taucs_csqrt_fn(x)
#define taucs_cimag(x) ((x).i)
#define taucs_creal(x) ((x).r)
#define taucs_cminusone taucs_cminusone_const
#define taucs_cone taucs_cone_const
#define taucs_czero taucs_czero_const
#if defined(TAUCS_CORE_DOUBLE)
#define taucs_add(x,y) ((x)+(y))
#define taucs_sub(x,y) ((x)-(y))
#define taucs_mul(x,y) ((x)*(y))
#define taucs_div(x,y) ((x)/(y))
#define taucs_neg(x) (-(x))
#define taucs_conj(x) (x)
#define taucs_abs(x) (fabs(x))
#define taucs_sqrt(x) (sqrt(x))
#define taucs_im(x) 0.0
#define taucs_re(x) (x)
#define taucs_minusone -1.0
#define taucs_one 1.0
#define taucs_zero 0.0
#elif defined(TAUCS_CORE_GENERAL)
/*
#define taucs_add(x,y) ((x)+(y))
#define taucs_sub(x,y) ((x)-(y))
#define taucs_mul(x,y) ((x)*(y))
#define taucs_div(x,y) ((x)/(y))
#define taucs_neg(x) (-(x))
#define taucs_conj(x) (x)
#define taucs_abs(x) (fabs(x))
#define taucs_sqrt(x) (sqrt(x))
*/
#define taucs_im(x) 0.0
#define taucs_re(x) (x)
#define taucs_minusone -1.0
#define taucs_one 1.0
#define taucs_zero 0.0
#elif defined(TAUCS_CORE_SINGLE)
#define taucs_add(x,y) ((x)+(y))
#define taucs_sub(x,y) ((x)-(y))
#define taucs_mul(x,y) ((x)*(y))
#define taucs_div(x,y) ((x)/(y))
#define taucs_neg(x) (-(x))
#define taucs_conj(x) (x)
#define taucs_abs(x) ((taucs_single) fabs(x))
#define taucs_sqrt(x) ((taucs_single) sqrt(x))
#define taucs_im(x) 0.0f
#define taucs_re(x) (x)
#define taucs_minusone -1.0f
#define taucs_one 1.0f
#define taucs_zero 0.0f
#elif defined(TAUCS_CORE_DCOMPLEX)
#define taucs_complex_create(r,i) taucs_zcomplex_create_fn(r,i)
#define taucs_add(x,y) taucs_zadd_fn(x,y)
#define taucs_sub(x,y) taucs_zsub_fn(x,y)
#define taucs_mul(x,y) taucs_zmul_fn(x,y)
#define taucs_div(x,y) taucs_zdiv_fn(x,y)
#define taucs_neg(x) taucs_zneg_fn(x)
#define taucs_conj(x) taucs_zconj_fn(x)
#define taucs_abs(x) taucs_zabs_fn(x)
#define taucs_sqrt(x) taucs_zsqrt_fn(x)
#define taucs_im(x) ((x).i)
#define taucs_re(x) ((x).r)
#define taucs_minusone taucs_zminusone_const
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?