00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifndef ASC_DIMEN_H
00032 #define ASC_DIMEN_H
00033
00038 #include <utilities/ascConfig.h>
00039 #include "compiler.h"
00040 #include "fractions.h"
00041
00042
00043
00044 #define NUM_DIMENS 10
00045 #define D_MASS 0
00046 #define D_QUANTITY 1
00047 #define D_LENGTH 2
00048 #define D_TIME 3
00049 #define D_TEMPERATURE 4
00050 #define D_CURRENCY 5
00051 #define D_ELECTRIC_CURRENT 6
00052 #define D_LUMINOUS_INTENSITY 7
00053 #define D_PLANE_ANGLE 8
00054 #define D_SOLID_ANGLE 9
00057 struct DimStruct {
00058 struct fraction f[NUM_DIMENS];
00059 unsigned int wild;
00060 };
00061 #define DIM_WILD 0x1
00062
00065 typedef struct DimStruct dim_type;
00066
00067 ASC_DLLSPEC struct gl_list_t *g_dimen_list;
00074 extern void InitDimenList(void);
00080 extern void DestroyDimenList(void);
00085 #define GetDimFraction(d,i) ((d).f[i])
00086
00101 #define GetDimPower(d,i) \
00102 (int)(Denominator((d).f[i])==1 ? Numerator((d).f[i]) : 0)
00103
00108 #define SetDimFraction(d,i,frac) ( (d).f[(i)] = (frac) )
00109
00113 ASC_DLLSPEC void ClearDimensions(dim_type *d);
00118 ASC_DLLSPEC CONST dim_type*Dimensionless(void);
00123 ASC_DLLSPEC CONST dim_type *TrigDimension(void);
00128 ASC_DLLSPEC CONST dim_type *WildDimension(void);
00134 extern CONST dim_type *HalfDimension(CONST dim_type *d, int b);
00141 extern CONST dim_type *ThirdDimension(CONST dim_type *d, int b);
00148 extern CONST dim_type *SquareDimension(CONST dim_type *d, int b);
00155 extern CONST dim_type *CubeDimension(CONST dim_type *d, int b);
00162 extern CONST dim_type *PowDimension(long mult, CONST dim_type *d, int b);
00170 extern void SetWild(dim_type *dim);
00175 ASC_DLLSPEC int IsWild(CONST dim_type *d);
00180 extern int OddDimension(CONST dim_type *d);
00185 extern int NonCubicDimension(CONST dim_type *d);
00190 extern int SameDimen(CONST dim_type *d1, CONST dim_type *d2);
00198 ASC_DLLSPEC int CmpDimen(CONST dim_type *d1, CONST dim_type *d2);
00203 ASC_DLLSPEC CONST dim_type *FindOrAddDimen(CONST dim_type *d);
00218 ASC_DLLSPEC void CopyDimensions(CONST dim_type *src, dim_type *dest);
00223 ASC_DLLSPEC dim_type AddDimensions(CONST dim_type *d1, CONST dim_type *d2);
00233 extern CONST dim_type *SumDimensions(CONST dim_type *d1, CONST dim_type *d2, int check);
00243 ASC_DLLSPEC dim_type SubDimensions(CONST dim_type *d1, CONST dim_type *d2);
00253 extern CONST dim_type *DiffDimensions(CONST dim_type *d1, CONST dim_type *d2, int check);
00263 ASC_DLLSPEC dim_type ScaleDimensions(CONST dim_type *dim, struct fraction frac);
00268 ASC_DLLSPEC void ParseDim(dim_type *dim, CONST char *c);
00288 ASC_DLLSPEC char *DimName(CONST int nIndex);
00294 extern CONST dim_type *CheckDimensionsMatch(CONST dim_type *d1, CONST dim_type *d2);
00303 ASC_DLLSPEC void PrintDimen(FILE *f ,CONST dim_type *d);
00307 ASC_DLLSPEC void PrintDimenMessage(CONST char *message
00308 , CONST char *label1, CONST dim_type *d1
00309 , CONST char *label2, CONST dim_type *d2
00310 );
00311
00314 ASC_DLLSPEC void DumpDimens(FILE *f);
00317
00318
00319 #endif