00001 #include <string.h>
00002 #include "inicd.h"
00003
00004
00005
00006
00007
00008
00009
00010
00011 inicd::inicd (void)
00012 {
00013 val = NULL;
00014 nval = 0L;
00015 type = none;
00016 }
00017
00018
00019
00020
00021
00022
00023
00024
00025 inicd::~inicd(void)
00026 {
00027 delete [] val;
00028 }
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 void inicd :: read(XFILE *in)
00042 {
00043
00044
00045 xfscanf(in, "%k%m", "ini_cd_type" , &inictype_kwdset, &type);
00046 xfscanf(in, "%k%ld", "nval", &nval);
00047
00048 val = new double[nval];
00049 memset(val, 0, sizeof(*val)*nval);
00050
00051 for (long i = 0; i < nval; i++)
00052 xfscanf(in, "%le", val+i);
00053 }
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066 void inicd::print(FILE *out)
00067 {
00068 fprintf(out, " %d", type);
00069 fprintf(out, " %ld", nval);
00070 for (long i = 0; i < nval; i++)
00071 fprintf(out, " %e", val[i]);
00072 fprintf(out, "\n");
00073 }
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086 void inicd::copy(inicd &ic)
00087 {
00088 long i;
00089
00090 if (val != NULL)
00091 delete [] val;
00092 type = ic.type;
00093 nval = ic.nval;
00094 val = new double[nval];
00095 for (i=0; i<nval; i++)
00096 val[i] = ic.val[i];
00097 }
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111 long inicd::merge(inicd &ic)
00112 {
00113 long i;
00114 if (ic.type == none)
00115 return 0;
00116 if (type == none)
00117 {
00118 type = ic.type;
00119 nval = ic.nval;
00120 val = new double[nval];
00121 for (i=0; i<nval; i++)
00122 val[i] = ic.val[i];
00123 return 0;
00124 }
00125 if ((ic.type == type) && (ic.nval == nval))
00126 {
00127 for (i=0; i<nval; i++)
00128 val[i] += ic.val[i];
00129 return 0;
00130 }
00131 return 1;
00132 }