28 #include <lal/LALInference.h>
29 #include <lal/Units.h>
30 #include <lal/FrequencySeries.h>
31 #include <lal/Sequence.h>
32 #include <lal/TimeSeries.h>
33 #include <lal/TimeFreqFFT.h>
34 #include <lal/VectorOps.h>
36 #include <lal/XLALError.h>
37 #include <gsl/gsl_vector.h>
38 #include <gsl/gsl_matrix.h>
39 #include <gsl/gsl_eigen.h>
40 #include <gsl/gsl_interp.h>
41 #include <lal/LALHashFunc.h>
42 #include <lal/LALSimNeutronStar.h>
45 #define UNUSED __attribute__ ((unused))
53 typedef struct taghash_elem
109 gettimeofday(&tv, NULL);
143 for (t = 0; t < nthreads; t++)
165 if(
a->size1!=b->size1 ||
a->size2!=b->size2)
return 0;
167 for(
i=0;
i<
a->size1;
i++)
168 for(
j=0;
j<
a->size2;
j++)
169 if(gsl_matrix_get(
a,
i,
j)!=gsl_matrix_get(b,
i,
j))
181 if(vars==NULL)
return NULL;
187 (
const void **)&match
189 if(!match)
return NULL;
198 while (
this != NULL) {
199 if (!strcmp(this->name,
name))
break;
200 else this = this->next;
216 while (
this != NULL) {
256 INT4 count_vectors = 1;
267 if (
ptr==NULL)
return count;
270 while (
ptr != NULL) {
280 count += (
INT4)( (
m->size1)*(
m->size2) );
303 count += (
int)(v8->
length);
310 count += (
int)(v16->
length);
331 if ((idx < 1) || (idx > vars->
dimension)){
344 if ((idx < 1) || (idx > vars->
dimension)){
368 switch (item->
type) {
370 gsl_matrix_free(*(gsl_matrix **)item->
value);
431 if(
new==NULL||new->value==NULL) {
442 new->next = vars->
head;
458 if(!strcmp(this->name,
name))
break;
459 else {parent=
this;
this=this->next;}
465 if(!parent) vars->
head=this->next;
466 else parent->
next=this->next;
469 elem.name=this->name;
472 switch (this->
type) {
474 gsl_matrix_free(*(gsl_matrix **)this->value);
538 if(
this) next=this->next;
548 if(
this) next=this->next;
564 if(origin==target)
return;
585 for (
i = dims;
i > 0;
i-- ){
602 gsl_matrix *old=*(gsl_matrix **)
ptr->
value;
603 gsl_matrix *
new=gsl_matrix_alloc(old->size1,old->size2);
605 gsl_matrix_memcpy(
new,old);
613 if(
new) memcpy(new->data,old->
data,new->length*
sizeof(new->data[0]));
622 if(
new) memcpy(new->data,old->
data,new->length*
sizeof(new->data[0]));
631 if(
new) memcpy(new->data,old->
data,new->length*
sizeof(
REAL8));
640 if(
new) memcpy(new->data,old->
data,new->length*
sizeof(
COMPLEX16));
677 sprintf(valopt,
"--%s",
ptr->name);
714 snprintf(
out, strsize,
"%e + i*%e",
718 snprintf(
out, strsize,
"%e + i*%e",
724 char arrstr[31*vec->
length +1];
730 strncat(arrstr,
this,30);
732 size_t actual_len=strlen(arrstr) +1;
733 if(actual_len > strsize)
738 snprintf(
out,strsize,
"%s",arrstr);
744 char arrstr[31*vec->
length +1];
750 strncat(arrstr,
this,30);
752 size_t actual_len=strlen(arrstr) +1;
753 if(actual_len > strsize)
758 snprintf(
out,strsize,
"%s",arrstr);
770 char arrstr[31*vec->
length +1];
776 strncat(arrstr,
this,30);
778 size_t actual_len=strlen(arrstr) +1;
779 if(actual_len > strsize)
784 snprintf(
out,strsize,
"%s",arrstr);
805 fprintf(stdout,
"LALInferenceVariables:\n");
809 while (
ptr != NULL) {
834 fprintf(stdout,
"'COMPLEX16'");
837 fprintf(stdout,
"'INT4Vector'");
840 fprintf(stdout,
"'UINT4Vector'");
843 fprintf(stdout,
"'REAL8Vector'");
846 fprintf(stdout,
"'gslMatrix'");
849 fprintf(stdout,
"<unknown type>");
853 gsl_matrix *matrix = NULL;
895 matrix = *((gsl_matrix **)
ptr->
value);
896 fprintf(stdout,
"%ix%i]",(
int)(matrix->size1),(
int)(matrix->size2));
914 fprintf(stdout,
"<can't print>");
925 char *buffer=
XLALCalloc(bufsize,
sizeof(
char));
927 UINT4 required_size=0;
928 if(sample==NULL)
return;
933 if(bufsize < required_size)
935 bufsize=required_size;
950 char *buffer=
XLALCalloc(bufsize,
sizeof(
char));
952 UINT4 required_size=0;
953 if(sample==NULL)
return;
959 if(bufsize < required_size)
961 bufsize=required_size;
975 if (
p == NULL ||
fp == NULL)
return;
977 while (item != NULL) {
979 switch (item->
type) {
1019 INT4 i=0, par=0, col=0;
1023 INT4 nWantedCols = 0;
1024 for (col = 0; col < nCols; col++)
1025 nWantedCols += wantedCols[col];
1028 unsigned long starting_pos = ftell(input);
1029 INT4 nSamples = *nLines;
1031 if (nSamples == 0) {
1033 while ( (ch = getc(input)) != EOF) {
1037 fseek(input,starting_pos,SEEK_SET);
1044 for (
i = 0;
i < nSamples;
i++) {
1046 for (col = 0; col < nCols; col++) {
1047 nread =
fscanf(input,
"%lg", &val);
1049 fprintf(stderr,
"Cannot read sample from file (in %s, line %d)\n",
1050 __FILE__, __LINE__);
1054 if (wantedCols[col]) {
1055 sampleArray[
i*nWantedCols + par] = val;
1077 char *newline = strchr(record,
'\n');
1082 char *
p = strtok(record, delim);
1086 p = strtok(NULL, delim);
1104 const char *delimiters =
" \t";
1110 while (strcmp(
row[0],
"cycle") &&
str != NULL) {
1111 last_line = ftell(filestream);
1117 fprintf(stderr,
"Couldn't find column headers in PTMCMC file.\n");
1123 fseek(filestream, last_line, SEEK_SET);
1140 const char *delimiters =
" \t";
1142 REAL8 loglike, maxLogL=-INFINITY;
1145 unsigned long startPostBurnin = ftell(filestream);
1148 while (fgets(
str,
sizeof(
str), filestream) != NULL) {
1150 loglike = (
REAL8) atof(
row[logl_idx]);
1151 if (loglike > maxLogL)
1156 fseek(filestream, startPostBurnin, SEEK_SET);
1162 while (fgets(
str,
sizeof(
str), filestream) != NULL) {
1164 loglike = (
REAL8) atof(
row[logl_idx]);
1170 fprintf(stderr,
"Error burning in PTMCMC file.\n");
1189 for (
i=0;
i<burnin;
i++)
1194 fprintf(stderr,
"Error burning in file.\n");
1214 const char *delimiters =
" \n\t";
1220 for (
i=0;
i<col_count;
i++)
1243 for (
i = 0;
i < nRows;
i++) {
1246 for (
j = 0;
j < nSelCols;
j++) {
1247 if (selCols[
j] > nCols) {
1250 array[
i][
j] = inarray[
i][selCols[
j]];
1271 REAL8 acceptanceRate = 0;
1273 if(cycle==NULL ||
fp==NULL)
1279 acceptanceRate = accepted/(proposed==0 ? 1.0 : proposed);
1288 if (!strcmp(inName,
"a_spin1")) {
1290 }
else if (!strcmp(inName,
"a_spin2")) {
1292 }
else if (!strcmp(inName,
"tilt_spin1")) {
1294 }
else if (!strcmp(inName,
"tilt_spin2")) {
1296 }
else if (!strcmp(inName,
"chirpmass")) {
1298 }
else if (!strcmp(inName,
"eta")) {
1300 }
else if (!strcmp(inName,
"q")) {
1302 }
else if (!strcmp(inName,
"rightascension")) {
1304 }
else if (!strcmp(inName,
"declination")) {
1306 }
else if (!strcmp(inName,
"phase")) {
1308 }
else if (!strcmp(inName,
"polarisation")) {
1310 }
else if (!strcmp(inName,
"distance")) {
1312 }
else if (!strcmp(inName,
"polar_angle")) {
1320 if (!strcmp(inName,
"a1")) {
1321 strcpy(outName,
"a_spin1");
1322 }
else if (!strcmp(inName,
"a2")) {
1323 strcpy(outName,
"a_spin2");
1324 }
else if (!strcmp(inName,
"tilt1")) {
1325 strcpy(outName,
"tilt_spin1");
1326 }
else if (!strcmp(inName,
"tilt2")) {
1327 strcpy(outName,
"tilt_spin2");
1328 }
else if (!strcmp(inName,
"mc")) {
1329 strcpy(outName,
"chirpmass");
1330 }
else if (!strcmp(inName,
"eta")) {
1331 strcpy(outName,
"eta");
1332 }
else if (!strcmp(inName,
"q")) {
1333 strcpy(outName,
"q");
1334 }
else if (!strcmp(inName,
"ra")) {
1335 strcpy(outName,
"rightascension");
1336 }
else if (!strcmp(inName,
"dec")) {
1337 strcpy(outName,
"declination");
1338 }
else if (!strcmp(inName,
"phi_orb")) {
1339 strcpy(outName,
"phase");
1340 }
else if (!strcmp(inName,
"psi")) {
1341 strcpy(outName,
"polarisation");
1342 }
else if (!strcmp(inName,
"theta_jn")) {
1343 strcpy(outName,
"theta_jn");
1344 }
else if (!strcmp(inName,
"phi_jl")) {
1345 strcpy(outName,
"phi_jl");
1346 }
else if (!strcmp(inName,
"dist")) {
1347 strcpy(outName,
"distance");
1348 }
else if (!strcmp(inName,
"alpha")) {
1349 strcpy(outName,
"polar_angle");
1351 strcpy(outName, inName);
1361 while (
head != NULL) {
1403 while (
head != NULL) {
1453 gsl_matrix *matrix = NULL;
1455 while (
head != NULL) {
1459 matrix = *((gsl_matrix **)
head->value);
1460 for(
i=0;
i<(
int)matrix->size1;
i++)
1462 for(
j=0;
j<(
int)matrix->size2;
j++)
1484 if (var1 == var2)
return 0;
1487 if ((var1 == NULL) || (var2 == NULL))
1489 XLALPrintWarning(
"LALInferenceCompareVariables received a NULL input pointer\n");
1498 while ((ptr1 != NULL) && (result == 0)) {
1502 switch (ptr1->
type) {
1536 if(v1->
length!=v2->length) result=1;
1540 if(v1->
data[
i]!=v2->data[
i]){
1551 if(v1->
length!=v2->length) result=1;
1555 if(v1->
data[
i]!=v2->data[
i]){
1566 if(v1->
length!=v2->length) result=1;
1570 if(v1->
data[
i]!=v2->data[
i]){
1596 for (
i = 0;
i < nPoints;
i+=step) {
1608 return nPoints/step;
1620 gsl_matrix *
m = NULL;
1635 for(
j=0;
j<
m->size1;
j++)
1637 for(
k=0;
k<
m->size2;
k++)
1639 target[
p]=gsl_matrix_get(
m,
j,
k);
1648 for(
j=0; j<v->length;
j++)
1658 for(
j=0; j<v->length;
j++)
1686 gsl_matrix *
m = NULL;
1700 for(
j=0;
j<
m->size1;
j++)
1702 for(
k=0;
k<
m->size2;
k++)
1704 gsl_matrix_set(
m,
j,
k,origin[
p]);
1713 for(
j=0; j<v->length;
j++)
1723 for(
j=0; j<v->length;
j++)
1743 v16->
data[
j] = origin[
p];
1769 fprintf(stderr,
" Warning: ProcessParamsTable is a NULL pointer\n");
1773 while (
this!=NULL) {
1774 if (!strcmp(this->param,
name))
break;
1775 else this=this->next;
1797 while (input[
i] !=
'\0') {
1798 if ((
j==0) & (input[
i]==
'['))
j=1;
1799 if ((
j==1) & (input[
i]==
',')) ++*
n;
1800 if ((
j==1) & (input[
i]==
']')) {++*
n;
j=2;}
1805 *strings = (
char**)
XLALMalloc(
sizeof(
char*) * (*n));
1806 for (
i=0;
i<(*n); ++
i) (*strings)[
i] = (
char*)
XLALMalloc(
sizeof(
char)*512);
1810 while ((input[
i] !=
'\0') & (
j<3)) {
1812 if ((
j==0) & ((input[
i]!=
'[') & (input[
i]!=
' ')))
j=1;
1813 if (((
j==1)|(
j==2)) & (input[
i]==
',')) {(*strings)[
k][
l]=
'\0';
j=2; ++
k;
l=0;}
1814 if ((
j==1) & (input[
i]==
' '))
j=2;
1815 if ((
j==1) & (input[
i]==
']')) {(*strings)[
k][
l]=
'\0';
j=3;}
1816 if ((
j==2) & (input[
i]==
']')) {(*strings)[
k][
l]=
'\0';
j=3;}
1817 if ((
j==2) & ((input[
i]!=
']') & (input[
i]!=
',') & (input[
i]!=
' ')))
j=1;
1824 (*strings)[
k][
l] = input[
i];
1835 for(
int i=0;
i<argc;
i++)
1850 int argc = arglist->
length;
1852 char **argv = arglist->
data;
1859 while ((
i<argc) & (state<=3)) {
1861 dbldash = ((argv[
i][0]==
'-') && (argv[
i][1]==
'-'));
1875 else if (state==2) {
1889 else if (state==3) {
1920 while (
this!=NULL) {
1921 len+=strlen(this->param);
1922 len+=strlen(this->value);
1928 XLALPrintError(
"Calloc error, str is NULL (in %s, line %d)\n",__FILE__, __LINE__);
1933 strcpy (
str,
"Command line: ");
1935 while (
this!=NULL) {
1937 strcat (
str,this->param);
1939 strcat (
str,this->value);
1959 fprintf(stderr,
" ERROR: model is a null pointer at LALInferenceExecuteFT, exiting!.\n");
1964 XLALPrintError(
"freqhPlus and timeqhPlus are NULL at LALInferenceExecuteFT, exiting!");
1968 XLALPrintError(
"freqhCross and timeqhCross are NULL at LALInferenceExecuteFT, exiting!");
1977 XLALPrintError(
"Could not create COMPLEX16FrequencySeries in LALInferenceExecuteFT");
1983 XLALPrintError(
"model->window is NULL at LALInferenceExecuteFT: Exiting!");
1990 XLALPrintError(
"Could not window time-series in LALInferenceExecuteFT");
1995 XLALPrintError(
"model->timeToFreqFFTPlan is NULL at LALInferenceExecuteFT: Exiting!");
2011 XLALPrintError(
"Could not create COMPLEX16FrequencySeries in LALInferenceExecuteFT");
2019 XLALPrintError(
"Could not window time-series in LALInferenceExecuteFT");
2074 nread =
fscanf(inp,
" %lg ", ¶m);
2088 const size_t MAXSIZE=1024;
2089 const char *delimiters =
" \n\t";
2091 char **colNames = NULL;
2093 size_t colNamesLen=0, colNamesMaxLen=0;
2094 char *colName = NULL;
2096 if (!fgets(
header, MAXSIZE, inp)) {
2099 }
else if (strlen(
header) >= MAXSIZE-1) {
2106 colNames=(
char **)
XLALMalloc(2*
sizeof(
char *));
2112 colName=strtok(
header, delimiters);
2117 colName=strtok(NULL, delimiters);
2123 if (colNamesLen >= colNamesMaxLen) {
2124 colNamesMaxLen *= 2;
2125 colNames=
XLALRealloc(colNames, colNamesMaxLen*
sizeof(
char *));
2131 }
while (colName != NULL);
2134 colNames=
XLALRealloc(colNames, colNamesLen*
sizeof(
char *));
2141 if (colName == NULL) {
2144 else if (!strcmp(colName,
"dist")) {
2148 else if (!strcmp(colName,
"ra")) {
2152 else if (!strcmp(colName,
"psi")) {
2156 else if (!strcmp(colName,
"mc")) {
2160 else if (!strcmp(colName,
"phi_orb")) {
2164 else if (!strcmp(colName,
"eta")) {
2168 else if (!strcmp(colName,
"q")) {
2172 else if (!strcmp(colName,
"dec")) {
2176 else if (!strcmp(colName,
"a1")) {
2180 else if (!strcmp(colName,
"a2")) {
2195 prevPtr=&(thisPtr->
next);
2196 thisPtr=thisPtr->
next;
2198 if(!thisPtr)
return NULL;
2199 *prevPtr=thisPtr->
next;
2216 for(match=vars->
head,
this=match->
next;
this;
this=this->next)
2217 if(strcmp(match->name,this->name)<0)
2258 UINT4 N_output_array=0;
2297 double root = sqrt(0.25-
eta);
2298 double fraction = (0.5+root) / (0.5-root);
2299 *
m2 =
mc * (pow(1+fraction,0.2) / pow(fraction,0.6));
2300 *
m1 =
mc * (pow(1+1.0/fraction,0.2) / pow(1.0/fraction,0.6));
2309 double factor =
mc * pow(1 +
q, 1.0/5.0);
2310 *
m1 = factor * pow(
q, -3.0/5.0);
2311 *
m2 = factor * pow(
q, +2.0/5.0);
2323 *dQuadMon1=(dQuadMonS+dQuadMonA);
2324 *dQuadMon2=(dQuadMonS-dQuadMonA);
2334 *
lambda1=((
c-d)*lambdaT-(
a-b)*dLambdaT)/(2.*(b*
c-
a*d));
2335 *
lambda2=((
c+d)*lambdaT-(
a+b)*dLambdaT)/(2.*(
a*d-b*
c));
2342 REAL8 logp1_si=logp1-1.0;
2426 REAL8 logp1_si=logp1-1.0;
2440 double gamma[]={SDgamma0,SDgamma1,SDgamma2,SDgamma3};
2451 fprintf(stdout,
"NO EOS PARAMETERS FOUND\n");
2469 const double logpmin = 75.5;
2471 double dlogp = (logpmax - logpmin) / 100.;
2473 for (
int i = 0;
i < 4; ++
i) {
2474 pdat = exp(logpmin +
i * dlogp);
2477 if (mdat <= mdat_prev){
2478 fprintf(stdout,
"EOS has too few points. Sample rejected.\n");
2486 fprintf(stdout,
"spectral: %f %f %f %f\n",SDgamma0,SDgamma1,SDgamma2,SDgamma3);
2524 fprintf(stdout,
"ERROR: NO MASS PARAMETERS FOUND\n");
2543 REAL8 ns_max_mass = 0.;
2549 ns_max_mass = mass2;
2555 if(mass1_kg <= max_mass_kg && mass2_kg <= max_mass_kg && mass1_kg >= min_mass_kg && mass2_kg >= min_mass_kg && vsmax <= 1.1 && max_mass_kg >= ns_max_mass*
LAL_MSUN_SI){
2573 double p0 = 4.43784199e-13;
2574 double xmax = 12.3081;
2575 double pmax = p0 * exp(xmax);
2587 double logpmax = log(pmax);
2588 double logp0 = log(p0);
2589 double dlogp = (logpmax-logp0)/ndat;
2591 for(
i = 0;
i < (
int) ndat;
i++)
2593 pdat[
i] = exp(logp0 + dlogp*
i);
2594 xdat[
i] = log(pdat[
i]/p0);
2599 for(
i = 0;
i<(
int) ndat;
i++) {
2601 if(adat[
i] < 0.6 || adat[
i] > 4.5) {
2616 double Gamma, logGamma = 0;
2620 logGamma +=
gamma[
i]*pow(
x,(
double)
i);
2622 Gamma = exp(logGamma);
2648 if (cell->
ptsCov != NULL) {
2649 for (
i = 0;
i < cell->
dim;
i++) {
2656 for (
i = 0;
i < cell->
dim;
i++) {
2695 for (
i = 0;
i < ndim;
i++) {
2720 for (
i = 0;
i <
n;
i++) {
2721 if (
a[
i] != b[
i])
return 0;
2727 if (cell->
npts <= 1) {
2733 for (
i = 1;
i < cell->
npts;
i++) {
2742 size_t ptsSize = cell->
ptsSize;
2743 size_t npts = cell->
npts;
2744 size_t dim = cell->
dim;
2747 if ( npts == ptsSize ){
2748 REAL8 tmpArr[npts][dim];
2753 tmpArr[
i][
j] = cell->
pts[
i][
j];
2765 for(
UINT4 i=0;
i < 2*ptsSize;
i++ ){
2770 cell->
pts[
i][
j] = tmpArr[
i][
j];
2781 cell->
pts[npts][
i] = pt[
i];
2805 size_t dim = cell->
dim;
2806 size_t nextLevel = (
level+1)%dim;
2809 if (cell->
npts == 0) {
2813 }
else if (cell->
left == NULL && cell->
right == NULL) {
2830 for (
i = 0;
i < cell->
npts;
i++) {
2833 if (lowerPt[
level] <= mid) {
2848 if (pt[
level] <= mid) {
2859 for (
i = 0;
i <
n;
i++) {
2860 if (pt[
i] < low[
i] || pt[
i] > high[
i])
return 0;
2869 size_t dim = cell->
dim;
2870 size_t npts = cell->
npts;
2873 for (
i = 0;
i < dim;
i++) {
2877 for (
i = 0;
i < npts;
i++) {
2879 for (
j = 0;
j < dim;
j++) {
2884 for (
i = 0;
i < dim;
i++) {
2893 size_t npts = cell->
npts;
2894 size_t dim = cell->
dim;
2897 for (
i = 0;
i < dim;
i++) {
2899 for (
j = 0;
j < dim;
j++) {
2904 for (
i = 0;
i < npts;
i++) {
2909 for (
j = 0;
j < dim;
j++) {
2914 for (
k = 0;
k < dim;
k++) {
2918 cov[
j][
k] += (ptj - muj)*(ptk-muk);
2923 for (
i = 0;
i < cell->
dim;
i++) {
2925 for (
j = 0;
j < cell->
dim;
j++) {
2926 cov[
i][
j] /= (npts - 1);
2932 gsl_eigen_symmv_workspace *ws) {
2933 if (A != NULL) gsl_matrix_free(A);
2934 if (evects != NULL) gsl_matrix_free(evects);
2935 if (evals != NULL) gsl_vector_free(evals);
2936 if (ws != NULL) gsl_eigen_symmv_free(ws);
2940 size_t dim = cell->
dim;
2941 gsl_matrix *A = gsl_matrix_alloc(dim, dim);
2942 gsl_matrix *evects = gsl_matrix_alloc(dim, dim);
2943 gsl_vector *evals = gsl_vector_alloc(dim);
2944 gsl_eigen_symmv_workspace *ws = gsl_eigen_symmv_alloc(dim);
2952 if (A == NULL || evects == NULL || evals == NULL || ws == NULL) {
2958 for (
i = 0;
i < dim;
i++) {
2961 for (
j = 0;
j < dim;
j++) {
2962 gsl_matrix_set(A,
i,
j, cov[
i][
j]);
2967 if ((
status = gsl_eigen_symmv(A, evals, evects, ws)) != GSL_SUCCESS) {
2974 for (
i = 0;
i < dim;
i++) {
2977 for (
j = 0;
j < dim;
j++) {
2978 covEVs[
i][
j] = gsl_matrix_get(evects,
j,
i);
2989 memset(xe, 0, dim*
sizeof(
REAL8));
2991 for (
j = 0;
j < dim;
j++) {
2995 for (
i = 0;
i < dim;
i++) {
3005 memset(
x, 0, dim*
sizeof(
REAL8));
3007 for (
i = 0;
i < dim;
i++) {
3010 for (
j = 0;
j < dim;
j++) {
3011 x[
i] += evi[
j]*xe[
j];
3018 size_t dim = cell->
dim;
3019 size_t npts = cell->
npts;
3026 REAL8 *xe = NULL, *
x = NULL;
3039 for (
i = 0;
i < dim;
i++) {
3044 for (
i = 0;
i < npts;
i++) {
3047 for (
j = 0;
j < dim;
j++) {
3053 for (
j = 0;
j < dim;
j++) {
3054 if (xe[
j] < min[
j]) min[
j] = xe[
j];
3085 }
else if (cell->
npts == 0) {
3087 }
else if (cell->
npts == 1 || cell->
npts < Npts) {
3092 if (pt[
level] <= mid) {
3094 if (maybeCell == NULL) {
3103 if (maybeCell == NULL) {
3117 size_t ndim = cell->
dim;
3120 for (
i = 0;
i < ndim;
i++) {
3128 double logVol = 0.0;
3129 size_t ndim = cell->
dim;
3136 for (
i = 0;
i < ndim;
i++) {
3146 while (templateItem != NULL) {
3151 templateItem = templateItem->
next;
3158 while (templateItem != NULL) {
3163 templateItem = templateItem->
next;
3174 if (cell->
npts == 1) {
3179 for (
i = 0;
i < cell->
dim;
i++) {
3191 for (
i = 0;
i < cell->
dim;
i++) {
3197 for (
i = 0;
i < cell->
dim;
i++) {
3207 REAL8 *shiftedPt, *ept;
3217 for (
i = 0;
i < cell->
dim;
i++) {
3223 for (
i = 0;
i < cell->
dim;
i++) {
3237 REAL8 *proposed,
size_t Npts) {
3243 size_t npts = topCell->
npts;
3245 REAL8 logCurrentVolume, logProposedVolume;
3247 if (currentCell->
npts > 1) {
3263 if (proposedCell->
npts > 1) {
3275 REAL8 logCurrentCellFactor = log((
REAL8)currentCell->
npts / npts);
3276 REAL8 logProposedCellFactor = log((
REAL8)proposedCell->
npts / npts);
3278 return logCurrentCellFactor + logCurrentVolume - logProposedCellFactor - logProposedVolume;
3286 gsl_matrix *
m = NULL;
3287 gsl_vector *eigen = NULL;
3288 gsl_eigen_symm_workspace *workspace = NULL;
3292 m = gsl_matrix_alloc( dim,dim );
3293 gsl_matrix_memcpy(
m, matrix);
3296 eigen = gsl_vector_alloc ( dim );
3297 workspace = gsl_eigen_symm_alloc ( dim );
3300 gsl_eigen_symm (
m, eigen, workspace );
3303 for (
i = 0;
i < dim;
i++)
3306 if (eigen->data[
i]<0)
3308 printf(
"NEGATIVE EIGEN VALUE!!! PANIC\n");
3314 gsl_eigen_symm_free( workspace);
3316 gsl_vector_free(eigen);
3331 gsl_matrix *work=NULL;
3332 gsl_vector *result = NULL;
3335 if (!
vector || !matrix || !randParam)
3342 work = gsl_matrix_alloc(dim,dim);
3343 gsl_matrix_memcpy( work, matrix );
3346 gsl_linalg_cholesky_decomp(work);
3352 result = gsl_vector_alloc ( (
int)dim );
3353 for (
i = 0;
i < dim;
i++)
3355 gsl_vector_set (result,
i,
vector->data[
i]);
3359 gsl_blas_dtrmv(CblasLower, CblasNoTrans, CblasNonUnit, work, result);
3362 for (
i = 0;
i < dim;
i++)
3364 vector->data[
i]=gsl_vector_get (result,
i);
3368 gsl_matrix_free(work);
3369 gsl_vector_free(result);
3383 REAL4 chi=0.0, factor;
3387 if (!
vector || !matrix || !randParam)
3417 for (
i=0;
i<dim;
i++)
3426 double raw = (
a2>a1 ?
a2-a1 : a1-
a2);
3442 ang_mean=atan2(
ms,
mc);
3443 ang_mean = ang_mean<0? 2.0*
LAL_PI + ang_mean : ang_mean;
3454 fprintf(stderr,
"NULL state pointer!\n");
3460 fprintf(stderr,
"NULL data pointer!\n");
3466 if(
data->timeData) {
3467 fprintf(stderr,
"Checking timeData: ");
3470 if(
data->whiteTimeData) {
3471 fprintf(stderr,
"Checking whiteTimeData: ");
3474 if(
data->windowedTimeData) {
3475 fprintf(stderr,
"Checking windowedTimeData: ");
3478 if(
data->freqData) {
3479 fprintf(stderr,
"Checking freqData: ");
3482 if(
data->whiteFreqData) {
3483 fprintf(stderr,
"Checking whiteFreqData: ");
3486 if(
data->oneSidedNoisePowerSpectrum) {
3487 fprintf(stderr,
"Checking oneSidedNoisePowerSpectrum: ");
3495 fprintf(stderr,
"NULL thread pointer!\n");
3501 fprintf(stderr,
"NULL model pointer in thread %d!\n",
i);
3506 fprintf(stderr,
"Checking timehPlus in thread %d: ",
i);
3510 fprintf(stderr,
"Checking timehCross in thread %d: ",
i);
3514 fprintf(stderr,
"Checking freqhPlus in thread %d: ",
i);
3518 fprintf(stderr,
"Checking freqhCross in thread %d: ",
i);
3532 if(!series)
fprintf(stderr,
"Null REAL8TimeSeries *\n");
3534 if(!series->
data)
fprintf(stderr,
"NULL REAL8Sequence structure in REAL8TimeSeries\n");
3536 if(!series->
data->
data)
fprintf(stderr,
"NULL REAL8[] in REAL8Sequence\n");
3542 if(retcode>1)
fprintf(stderr,
"and %i more times\n",retcode);
3550 if(!series)
fprintf(stderr,
"Null REAL8FrequencySeries *\n");
3552 if(!series->
data)
fprintf(stderr,
"NULL REAL8Sequence structure in REAL8FrequencySeries\n");
3554 if(!series->
data->
data)
fprintf(stderr,
"NULL REAL8[] in REAL8Sequence\n");
3560 if(retcode>1)
fprintf(stderr,
"and %i more times\n",retcode);
3568 if(!series)
fprintf(stderr,
"Null COMPLEX16FrequencySeries *\n");
3570 if(!series->
data)
fprintf(stderr,
"NULL COMPLEX16Sequence structure in COMPLEX16FrequencySeries\n");
3572 if(!series->
data->
data)
fprintf(stderr,
"NULL REAL8[] in COMPLEX16Sequence\n");
3579 if(retcode>1)
fprintf(stderr,
"and %i more times\n",retcode);
3585 if(isinf(val))
return 1;
3586 if(isnan(val))
return 1;
3593 FILE *dumpfile=NULL;
3594 char basename[1024]=
"template_dump";
3596 if(basefilename!=NULL)
3598 sprintf(basename,
"%s",basefilename);
3699 if(!vars)
return -1;
3715 gsl_matrix *matrix=*(gsl_matrix **)item->
value;
3718 gsl_matrix_fwrite(
file,matrix);
3747 char *value = *((
char **)item->
value);
3748 size_t len = strlen(value);
3800 fprintf(stderr,
"ERROR reading saved variable!");
3812 gsl_matrix *matrix=gsl_matrix_alloc(size1,size2);
3813 gsl_matrix_fread(stream,matrix);
3847 char *
string = NULL;
3882 for (item = vars->
head; item; item = item->
next)
4260 gsl_interp_accel *ampAcc = NULL, *phaseAcc = NULL;
4261 gsl_interp *ampInterp = NULL, *phaseInterp = NULL;
4264 const char *
fmt =
"";
4268 if (logfreqs == NULL || deltaAmps == NULL || deltaPhases == NULL || calFactor == NULL) {
4276 fmt =
"input lengths differ";
4282 ampInterp = gsl_interp_alloc(gsl_interp_cspline,
N);
4283 phaseInterp = gsl_interp_alloc(gsl_interp_cspline,
N);
4285 if (ampInterp == NULL || phaseInterp == NULL) {
4287 fmt =
"could not allocate GSL interpolation objects";
4291 ampAcc = gsl_interp_accel_alloc();
4292 phaseAcc = gsl_interp_accel_alloc();
4294 if (ampAcc == NULL || phaseAcc == NULL) {
4296 fmt =
"could not allocate interpolation acceleration objects";
4300 gsl_interp_init(ampInterp, logfreqs->
data, deltaAmps->
data,
N);
4301 gsl_interp_init(phaseInterp, logfreqs->
data, deltaPhases->
data,
N);
4306 REAL8 dA = 0.0, dPhi = 0.0;
4309 if (f < lowf || f > highf) {
4313 dA = gsl_interp_eval(ampInterp, logfreqs->
data, deltaAmps->
data, log(f), ampAcc);
4314 dPhi = gsl_interp_eval(phaseInterp, logfreqs->
data, deltaPhases->
data, log(f), phaseAcc);
4317 calFactor->
data->
data[
i] = (1.0 + dA)*(2.0 + I*dPhi)/(2.0 - I*dPhi);
4321 if (ampInterp != NULL) gsl_interp_free(ampInterp);
4322 if (phaseInterp != NULL) gsl_interp_free(phaseInterp);
4323 if (ampAcc != NULL) gsl_interp_accel_free(ampAcc);
4324 if (phaseAcc != NULL) gsl_interp_accel_free(phaseAcc);
4341 gsl_interp_accel *ampAcc = NULL, *phaseAcc = NULL;
4342 gsl_interp *ampInterp = NULL, *phaseInterp = NULL;
4345 const char *
fmt =
"";
4351 if (logfreqs == NULL || deltaAmps == NULL || deltaPhases == NULL || freqNodesLin == NULL || freqNodesQuad == NULL) {
4357 if (logfreqs->
length != deltaAmps->
length || deltaAmps->
length != deltaPhases->
length || freqNodesLin->
length != (*calFactorROQLin)->length || freqNodesQuad->
length != (*calFactorROQQuad)->length) {
4359 fmt =
"input lengths differ";
4366 ampInterp = gsl_interp_alloc(gsl_interp_cspline,
N);
4367 phaseInterp = gsl_interp_alloc(gsl_interp_cspline,
N);
4369 if (ampInterp == NULL || phaseInterp == NULL) {
4371 fmt =
"could not allocate GSL interpolation objects";
4375 ampAcc = gsl_interp_accel_alloc();
4376 phaseAcc = gsl_interp_accel_alloc();
4378 if (ampAcc == NULL || phaseAcc == NULL) {
4380 fmt =
"could not allocate interpolation acceleration objects";
4384 gsl_interp_init(ampInterp, logfreqs->
data, deltaAmps->
data,
N);
4385 gsl_interp_init(phaseInterp, logfreqs->
data, deltaPhases->
data,
N);
4389 REAL8 dA = 0.0, dPhi = 0.0;
4391 for (
unsigned int i = 0;
i < freqNodesLin->
length;
i++) {
4393 if (f < lowf || f > highf) {
4397 dA = gsl_interp_eval(ampInterp, logfreqs->
data, deltaAmps->
data, log(f), ampAcc);
4398 dPhi = gsl_interp_eval(phaseInterp, logfreqs->
data, deltaPhases->
data, log(f), phaseAcc);
4401 (*calFactorROQLin)->data[
i] = (1.0 + dA)*(2.0 + I*dPhi)/(2.0 - I*dPhi);
4404 for (
unsigned int j = 0;
j < freqNodesQuad->
length;
j++) {
4406 if (f < lowf || f > highf) {
4410 dA = gsl_interp_eval(ampInterp, logfreqs->
data, deltaAmps->
data, log(f), ampAcc);
4411 dPhi = gsl_interp_eval(phaseInterp, logfreqs->
data, deltaPhases->
data, log(f), phaseAcc);
4414 (*calFactorROQQuad)->data[
j] = (1.0 + dA)*(2.0 + I*dPhi)/(2.0 - I*dPhi);
4419 if (ampInterp != NULL) gsl_interp_free(ampInterp);
4420 if (phaseInterp != NULL) gsl_interp_free(phaseInterp);
4421 if (ampAcc != NULL) gsl_interp_accel_free(ampAcc);
4422 if (phaseAcc != NULL) gsl_interp_accel_free(phaseAcc);
4433 char **ifo_names = NULL;
4440 for (
i=0;
i<nifo;
i++) {
4444 for (
j = 0;
j < ncal;
j++) {
4445 snprintf(parname,
VARNAME_MAX,
"%sspcalamp%02zd", ifo_names[
i],
j);
4449 for (
j = 0;
j < ncal;
j++) {
4450 snprintf(parname,
VARNAME_MAX,
"%sspcalphase%02zd", ifo_names[
i],
j);
4458 char **ifo_names = NULL;
4463 for (
i=0;
i<nifo;
i++) {
4472 snprintf(ampVarName,
VARNAME_MAX,
"%s_spcal_amp", ifo_names[
i]);
4473 snprintf(phaseVarName,
VARNAME_MAX,
"%s_spcal_phase", ifo_names[
i]);
4496 REAL8 lambdaSm1o5 = pow(lambdaS,-1.0/5.0);
4497 REAL8 lambdaSm2o5 = lambdaSm1o5*lambdaSm1o5;
4498 REAL8 lambdaSm3o5 = lambdaSm2o5*lambdaSm1o5;
4499 REAL8 lambdaSsqrt = sqrt(lambdaS);
4516 REAL8 q_for_Fnofq = pow(
q,10.0/(3.0-BL_n));
4517 REAL8 Fnofq = (1.0-q_for_Fnofq)/(1.0+q_for_Fnofq);
4521 REAL8 b11 = -27.7408;
4522 REAL8 b12 = 8.42358;
4523 REAL8 b21 = 122.686;
4524 REAL8 b22 = -19.7551;
4525 REAL8 b31 = -175.496;
4526 REAL8 b32 = 133.708;
4528 REAL8 c11 = -25.5593;
4529 REAL8 c12 = 5.58527;
4530 REAL8 c21 = 92.0337;
4531 REAL8 c22 = 26.8586;
4532 REAL8 c31 = -70.247;
4537 REAL8 numerator = 1.0 + (b11*
q*lambdaSm1o5) + (b12*q2*lambdaSm1o5) + (b21*
q*lambdaSm2o5) + (b22*q2*lambdaSm2o5) + (b31*
q*lambdaSm3o5) + (b32*q2*lambdaSm3o5);
4539 REAL8 denominator = 1.0 + (c11*
q*lambdaSm1o5) + (c12*q2*lambdaSm1o5) + (c21*
q*lambdaSm2o5) + (c22*q2*lambdaSm2o5) + (c31*
q*lambdaSm3o5) + (c32*q2*lambdaSm3o5);
4541 REAL8 lambdaA_fitOnly = Fnofq*lambdaS*numerator/denominator;
4546 REAL8 lambdaA_lambdaS_meanCorr = (137.1252739/(lambdaS*lambdaS)) - (32.8026613/lambdaS) + 0.5168637;
4551 REAL8 lambdaA_lambdaS_stdCorr = (-0.0000739*lambdaS*lambdaSsqrt) + (0.0103778*lambdaS) + (0.4581717*lambdaSsqrt) - 0.8341913;
4556 REAL8 lambdaA_q_meanCorr = (-11.2765281*q2) + (14.9499544*
q) - 4.6638851;
4561 REAL8 lambdaA_q_stdCorr = (-201.4323962*q2) + (273.9268276*
q) - 71.2342246;
4565 REAL8 lambdaA_meanCorr = (lambdaA_lambdaS_meanCorr + lambdaA_q_meanCorr)/2.0;
4569 REAL8 lambdaA_stdCorr = sqrt((lambdaA_lambdaS_stdCorr*lambdaA_lambdaS_stdCorr) + (lambdaA_q_stdCorr*lambdaA_q_stdCorr));
4576 REAL8 lambdaA_scatter = gsl_cdf_gaussian_Pinv(BLuni, lambdaA_stdCorr);
4580 REAL8 lambdaA = lambdaA_fitOnly + (lambdaA_meanCorr + lambdaA_scatter);
static COMPLEX16Vector * COMPLEX16Vector_fread(FILE *f)
static REAL8Vector * REAL8Vector_fread(FILE *f)
static void INT4Vector_fwrite(FILE *f, INT4Vector *vec)
static int LALInferenceElemCmp(const void *elem1, const void *elem2)
static void computeMean(LALInferenceKDTree *cell)
static void updateEigenSystem(LALInferenceKDTree *cell)
static void del_elem(void *elem)
static int cellAllEqualPoints(LALInferenceKDTree *cell)
ProcessParamsTable * LALInferenceParseCommandLine(int argc, char *argv[])
static INT4Vector * INT4Vector_fread(FILE *f)
static void computeCovariance(LALInferenceKDTree *cell)
static int inEigenBox(LALInferenceKDTree *cell, REAL8 *pt)
static void deleteCell(LALInferenceKDTree *cell)
static LALInferenceVariableItem * LALInferenceGetItemSlow(const LALInferenceVariables *vars, const char *name)
static UINT4Vector * UINT4Vector_fread(FILE *f)
static INT4 checkREAL8TimeSeries(REAL8TimeSeries *series)
static INT4 checkREAL8Value(REAL8 val)
static LALInferenceKDTree * newCell(size_t ndim, REAL8 *lowerLeft, REAL8 *upperRight, size_t level, cellType type)
static void toEigenFrame(size_t dim, REAL8 **eigenvs, REAL8 *x, REAL8 *xe)
static void * new_elem(const char *name, LALInferenceVariableItem *itemPtr)
static LALInferenceKDTree * doFindCell(LALInferenceKDTree *cell, REAL8 *pt, size_t dim, size_t Npts, size_t level)
static void fromEigenFrame(size_t dim, REAL8 **eigenvs, REAL8 *xe, REAL8 *x)
static void REAL8Vector_fwrite(FILE *f, REAL8Vector *vec)
static void UINT4Vector_fwrite(FILE *f, UINT4Vector *vec)
static void computeEigenVectorsCleanup(gsl_matrix *A, gsl_matrix *evects, gsl_vector *evals, gsl_eigen_symmv_workspace *ws)
static INT4 checkCOMPLEX16FrequencySeries(COMPLEX16FrequencySeries *series)
static void computeEigenVectors(LALInferenceKDTree *cell)
static int inBounds(REAL8 *pt, REAL8 *low, REAL8 *high, size_t n)
static INT4 checkREAL8FrequencySeries(REAL8FrequencySeries *series)
static int equalPoints(REAL8 *a, REAL8 *b, size_t n)
static INT4 matrix_equal(gsl_matrix *a, gsl_matrix *b)
static void addPtToCellPts(LALInferenceKDTree *cell, REAL8 *pt)
static char * colNameToParamName(const char *colName)
static void computeEigenMinMax(LALInferenceKDTree *cell)
static UINT8 LALInferenceElemHash(const void *elem)
static void COMPLEX16Vector_fwrite(FILE *f, COMPLEX16Vector *vec)
static int insertIntoCell(LALInferenceKDTree *cell, REAL8 *pt, size_t level)
static REAL8 mean(REAL8 *array, int N)
static REAL8 norm(const REAL8 x[3])
void LALCheckMemoryLeaks(void)
struct tagLALSimNeutronStarFamily LALSimNeutronStarFamily
struct tagLALSimNeutronStarEOS LALSimNeutronStarEOS
COMPLEX16FrequencySeries * XLALCreateCOMPLEX16FrequencySeries(const CHAR *name, const LIGOTimeGPS *epoch, REAL8 f0, REAL8 deltaF, const LALUnit *sampleUnits, size_t length)
UINT8 XLALCityHash64(const char *buf, size_t len)
int XLALHashTblFind(const LALHashTbl *ht, const void *x, const void **y)
LALHashTbl * XLALHashTblCreate(LALHashTblDtorFcn dtor, LALHashTblHashFcn hash, LALHashTblCmpFcn cmp)
int XLALHashTblAdd(LALHashTbl *ht, void *x)
int XLALHashTblRemove(LALHashTbl *ht, const void *x)
void XLALHashTblDestroy(LALHashTbl *ht)
void LALInferenceMcQ2Masses(double mc, double q, double *m1, double *m2)
Convert from Mc, q space to m1, m2 space (q = m2/m1, with m1 > m2).
REAL8 LALInferenceAngularDistance(REAL8 a1, REAL8 a2)
Calculate shortest angular distance between a1 and a2 (modulo 2PI)
INT4 LALInferenceBufferToArray(LALInferenceThreadState *thread, REAL8 **DEarray)
LALInferenceThreadState * LALInferenceInitThreads(INT4 nthreads)
int LALInferenceKDAddPoint(LALInferenceKDTree *tree, REAL8 *pt)
Adds a point to the kD-tree, returns 0 on successful exit.
INT4 LALInferenceThinnedBufferToArray(LALInferenceThreadState *thread, REAL8 **DEarray, INT4 step)
LALInferenceVariable buffer to array and vica versa.
void LALInferencePrintSampleNonFixed(FILE *fp, LALInferenceVariables *sample)
Output only non-fixed parameters.
void LALInferenceReadAsciiHeader(FILE *input, char params[][VARNAME_MAX], INT4 *nCols)
Read column names from an ASCII file.
void LALInferenceAddINT8Variable(LALInferenceVariables *vars, const char *name, INT8 value, LALInferenceParamVaryType vary)
int LALInferenceReadVariablesArrayBinary(FILE *file, LALInferenceVariables **vars, UINT4 N)
Read N LALInferenceVariables from the binary FILE *file, previously written with LALInferenceWriteVar...
INT4 LALInferenceGetVariableDimensionNonFixedChooseVectors(LALInferenceVariables *vars, INT4 count_vectors)
Get number of dimensions in vars which are not fixed to a certain value, with a flag for skipping cou...
REAL8 * LALInferenceParseDelimitedAscii(FILE *input, INT4 nCols, INT4 *wantedCols, INT4 *nLines)
Utility for readling in delimited ASCII files.
void LALInferenceSetstringVariable(LALInferenceVariables *vars, const char *name, const CHAR *value)
void LALInferencedQuadMonSdQuadMonA(REAL8 dQuadMonS, REAL8 dQuadMonA, REAL8 *dQuadMon1, REAL8 *dQuadMon2)
Convert from dQuadMonS, dQuadMonA to dQuadMon1, dQuadMon2.
LALInferenceMCMCRunPhase * LALInferenceGetMCMCrunphase_ptrVariable(LALInferenceVariables *vars, const char *name)
LALInferenceVariableType LALInferenceGetVariableType(const LALInferenceVariables *vars, const char *name)
Get the LALInferenceVariableType of the parameter named name in vars.
void LALInferenceDiscardPTMCMCHeader(FILE *filestream)
Discard the standard header of a PTMCMC chain file.
void LALInferenceQ2Eta(double q, double *eta)
Convert from q to eta (q = m2/m1, with m1 > m2).
int LALInferenceFprintParameterNonFixedHeaders(FILE *out, LALInferenceVariables *params)
Print the parameters which do not vary to a file as a tab-separated ASCII line.
UINT4 LALInferenceGetUINT4Variable(LALInferenceVariables *vars, const char *name)
void LALInferencePrintSample(FILE *fp, LALInferenceVariables *sample)
Output the sample to file *fp, in ASCII format.
INT4 LALInferenceGetVariableDimensionNonFixed(LALInferenceVariables *vars)
Get number of dimensions in vars which are not fixed to a certain value.
char ** LALInferenceGetHeaderLine(FILE *inp)
Returns an array of header strings (terminated by NULL) from a common-format output file.
gsl_matrix * LALInferenceGetgslMatrixVariable(LALInferenceVariables *vars, const char *name)
int LALInferenceFprintParameterHeaders(FILE *out, LALInferenceVariables *params)
Print the parameter names to a file as a tab-separated ASCII line.
double AdiabaticIndex(double gamma[], double x, int size)
Specral decomposition of eos's adiabatic index.
REAL8Vector * LALInferenceGetREAL8VectorVariable(LALInferenceVariables *vars, const char *name)
int LALInferenceSplineCalibrationFactorROQ(REAL8Vector *logfreqs, REAL8Vector *deltaAmps, REAL8Vector *deltaPhases, REAL8Sequence *freqNodesLin, COMPLEX16Sequence **calFactorROQLin, REAL8Sequence *freqNodesQuad, COMPLEX16Sequence **calFactorROQQuad)
Modified version of LALInferenceSplineCalibrationFactor to compute the calibration factors for the sp...
void LALInferenceAddREAL8VectorVariable(LALInferenceVariables *vars, const char *name, REAL8Vector *value, LALInferenceParamVaryType vary)
void LALInferencePrintSplineCalibration(FILE *output, LALInferenceThreadState *thread)
Output spline calibration parameters.
void LALInferenceAddVariable(LALInferenceVariables *vars, const char *name, const void *value, LALInferenceVariableType type, LALInferenceParamVaryType vary)
Add a variable named name to vars with initial value referenced by value.
REAL4 LALInferenceGetREAL4Variable(LALInferenceVariables *vars, const char *name)
double LALInferenceKDLogCellVolume(LALInferenceKDTree *cell)
Returns the log of the volume of the given cell, which is part of the given tree.
int LALInferenceWriteVariablesArrayBinary(FILE *file, LALInferenceVariables **vars, UINT4 N)
Write an array N of LALInferenceVariables to the given FILE * using LALInferenceWriteVariablesBinary(...
void LALInferenceKDVariablesToREAL8(LALInferenceVariables *params, REAL8 *pt, LALInferenceVariables *templt)
Fills in the given REAL8 array with the parameter values from params; the ordering of the variables i...
LALInferenceThreadState * LALInferenceInitThread(LALInferenceThreadState *thread)
Structure to contain data-related Reduced Order Quadrature quantities.
void LALInferenceAddINT4VectorVariable(LALInferenceVariables *vars, const char *name, INT4Vector *value, LALInferenceParamVaryType vary)
int LALInferenceWriteRunStateBinary(FILE *file, LALInferenceRunState *runState)
Write the LALInferenceVariables contents of runState to a file in binary format.
void LALInferenceLogSampleToFile(LALInferenceVariables *algorithmParams, LALInferenceVariables *vars)
Append the sample to a file.
UINT4 LALInferencePrintNVariableItem(char *out, UINT4 strsize, const LALInferenceVariableItem *const ptr)
Prints a variable item to a string (must be pre-allocated!) Returns the number of bytes necessary to ...
void LALInferenceLogp1GammasMasses2Lambdas(REAL8 logp1, REAL8 gamma1, REAL8 gamma2, REAL8 gamma3, REAL8 mass1, REAL8 mass2, REAL8 *lambda1, REAL8 *lambda2)
Calculate lambda1,2(m1,2|eos(logp1,gamma1,gamma2,gamma3))
REAL8 LALInferenceGetREAL8Variable(LALInferenceVariables *vars, const char *name)
REAL8 LALInferenceKDLogProposalRatio(LALInferenceKDTree *tree, REAL8 *current, REAL8 *proposed, size_t Npts)
Returns the log of the jump proposal probability ratio for the LALInferenceKDDrawEigenFrame() proposa...
REAL8 ** LALInferenceSelectColsFromArray(REAL8 **inarray, INT4 nRows, INT4 nCols, INT4 nSelCols, INT4 *selCols)
Utility for selecting columns from an array, in the specified order.
COMPLEX8 LALInferenceGetCOMPLEX8Variable(LALInferenceVariables *vars, const char *name)
void LALInferenceSetREAL8Variable(LALInferenceVariables *vars, const char *name, REAL8 value)
void LALInferenceExecuteFT(LALInferenceModel *model)
Execute FFT for data in IFOdata.
size_t LALInferenceTypeSize[]
double LALInferenceKDLogCellEigenVolume(LALInferenceKDTree *cell)
Returns the log of the volume of the box aligned with the principal axes of the points in the given c...
int LALInferenceCompareVariables(LALInferenceVariables *var1, LALInferenceVariables *var2)
Check for equality in two variables.
int LALInferenceEOSPhysicalCheck(LALInferenceVariables *params, ProcessParamsTable *commandLine)
Check for causality violation and mass conflict given masses and eos.
char * LALInferenceGetVariableName(LALInferenceVariables *vars, int idx)
Get the name of the idx-th variable Indexing starts at 1.
void LALInferenceRemoveVariable(LALInferenceVariables *vars, const char *name)
Remove name from vars Frees the memory for the name structure and its contents.
LALInferenceKDTree * LALInferenceKDFindCell(LALInferenceKDTree *tree, REAL8 *pt, size_t Npts)
Returns the first cell that contains the given point that also contains fewer than Npts points,...
void LALInferenceAddstringVariable(LALInferenceVariables *vars, const char *name, const CHAR *value, LALInferenceParamVaryType vary)
void LALInferenceLambdaTsEta2Lambdas(REAL8 lambdaT, REAL8 dLambdaT, REAL8 eta, REAL8 *lambda1, REAL8 *lambda2)
Convert from lambdaT, dLambdaT, and eta to lambda1 and lambda2.
INT4 LALInferenceGetVariableTypeByIndex(LALInferenceVariables *vars, int idx)
Get the LALInferenceVariableType of the idx -th item in the vars Indexing starts at 1.
int LALInferenceSDGammaCheck(double gamma[], int size)
Determine if the Adiabatic index is within 'prior' range.
LALInferenceParamVaryType
An enumerated type for denoting the topology of a parameter.
void LALInferenceReadSampleNonFixed(FILE *fp, LALInferenceVariables *p)
Read in the non-fixed parameters from the given file (position in the file must be arranged properly ...
void LALInferenceSetCOMPLEX16Variable(LALInferenceVariables *vars, const char *name, COMPLEX16 value)
void LALInferenceSetUINT4VectorVariable(LALInferenceVariables *vars, const char *name, UINT4Vector *value)
void LALInferenceAddCOMPLEX16VectorVariable(LALInferenceVariables *vars, const char *name, COMPLEX16Vector *value, LALInferenceParamVaryType vary)
void LALInferenceDumpWaveforms(LALInferenceModel *model, const char *basefilename)
Dump all waveforms from the ifodata structure.
void LALInferenceSetCOMPLEX16VectorVariable(LALInferenceVariables *vars, const char *name, COMPLEX16Vector *value)
void LALInferenceCopyVariables(LALInferenceVariables *origin, LALInferenceVariables *target)
Deep copy the variables from one to another LALInferenceVariables structure.
void LALInferenceBurninStream(FILE *filestream, INT4 burnin)
Burn-in a generic ASCII stream.
void LALInferenceAddREAL8Variable(LALInferenceVariables *vars, const char *name, REAL8 value, LALInferenceParamVaryType vary)
INT4 LALInferenceGetINT4Variable(LALInferenceVariables *vars, const char *name)
ProcessParamsTable * LALInferenceParseStringVector(LALStringVector *arglist)
Return a ProcessParamsTrable from a string vector.
void LALInferenceAddUINT4Variable(LALInferenceVariables *vars, const char *name, UINT4 value, LALInferenceParamVaryType vary)
REAL8 LALInferenceAngularVariance(LALInferenceVariables **list, const char *pname, int N)
Calculate the variance of a distribution on an angle (modulo 2PI)
int LALInferencePrintProposalStatsHeader(FILE *fp, LALInferenceProposalCycle *cycle)
Output proposal statistics header to file *fp.
void LALInferenceKDDrawEigenFrame(gsl_rng *rng, LALInferenceKDTree *tree, REAL8 *pt, size_t Npts)
Draws a pt uniformly from a randomly chosen cell of tree.
void LALInferencePrintProposalStats(FILE *fp, LALInferenceProposalCycle *cycle)
Output proposal statistics to file *fp.
void LALInferenceProcessParamLine(FILE *inp, char **headers, LALInferenceVariables *vars)
Reads one line from the given file and stores the values there into the variable structure,...
COMPLEX16Vector * LALInferenceGetCOMPLEX16VectorVariable(LALInferenceVariables *vars, const char *name)
void LALInferenceAddCOMPLEX16Variable(LALInferenceVariables *vars, const char *name, COMPLEX16 value, LALInferenceParamVaryType vary)
void LALInferenceAddINT4Variable(LALInferenceVariables *vars, const char *name, INT4 value, LALInferenceParamVaryType vary)
LALInferenceKDTree * LALInferenceKDEmpty(REAL8 *lowerLeft, REAL8 *upperRight, size_t ndim)
Constructs a fresh, empty kD tree.
INT4Vector * LALInferenceGetINT4VectorVariable(LALInferenceVariables *vars, const char *name)
void LALInferenceFprintSplineCalibrationHeader(FILE *output, LALInferenceThreadState *thread)
Print spline calibration parameter names as tab-separated ASCII.
LALInferenceMCMCRunPhase
Phase of MCMC run (depending on burn-in status, different actions are performed during the run,...
ProcessParamsTable * LALInferenceParseCommandLineStringVector(LALStringVector *args)
Return a ProcessParamsTable from the command line arguments (SWIG version)
void LALInferenceCopyArrayToVariables(REAL8 *origin, LALInferenceVariables *target)
void LALInferenceKDTreeDelete(LALInferenceKDTree *tree)
Delete a kD-tree.
void LALInferenceSetParamVaryType(LALInferenceVariables *vars, const char *name, LALInferenceParamVaryType vary)
Set the LALInferenceParamVaryType of the parameter named name in vars, see the declaration of LALInfe...
UINT4Vector * LALInferenceGetUINT4VectorVariable(LALInferenceVariables *vars, const char *name)
void LALInferenceSetUINT4Variable(LALInferenceVariables *vars, const char *name, UINT4 value)
void LALInferenceBurninPTMCMC(FILE *filestream, INT4 logl_idx, INT4 nPar)
Determine burnin cycle from delta-logl criteria.
INT4 LALInferenceGetVariableDimension(LALInferenceVariables *vars)
Get number of dimensions in variable vars.
void LALInferenceAddMCMCrunphase_ptrVariable(LALInferenceVariables *vars, const char *name, LALInferenceMCMCRunPhase *value, LALInferenceParamVaryType vary)
void LALInferenceSetINT4Variable(LALInferenceVariables *vars, const char *name, INT4 value)
int LALInferenceCheckVariableToPrint(LALInferenceVariables *vars, const char *name)
UINT4 LALInferenceCheckPositiveDefinite(gsl_matrix *matrix, UINT4 dim)
Check matrix is positive definite.
void LALInferenceSDGammasMasses2Lambdas(REAL8 gamma[], REAL8 mass1, REAL8 mass2, REAL8 *lambda1, REAL8 *lambda2, int size)
Convert from spectral parameters to lambda1, lambda2.
void LALInferenceParseCharacterOptionString(char *input, char **strings[], UINT4 *n)
parses a character string (passed as one of the options) and decomposes it into individual parameter ...
void LALInferenceClearVariables(LALInferenceVariables *vars)
Delete the variables in this structure.
LALInferenceVariableItem * LALInferencePopVariableItem(LALInferenceVariables *vars, const char *name)
Pop the list node for "name".
void LALInferenceSortVariablesByName(LALInferenceVariables *vars)
Sorts the variable structure by name.
void XLALMultiStudentDeviates(REAL4Vector *vector, gsl_matrix *matrix, UINT4 dim, UINT4 n, RandomParams *randParam)
Draw a random multivariate vector from student-t distr given covariance matrix.
void LALInferenceSetINT4VectorVariable(LALInferenceVariables *vars, const char *name, INT4Vector *value)
void LALInferenceAddgslMatrixVariable(LALInferenceVariables *vars, const char *name, gsl_matrix *value, LALInferenceParamVaryType vary)
void parseLine(char *record, const char *delim, char arr[][VARNAME_MAX], INT4 *cnt)
Parse a single line of delimited ASCII.
void LALInferenceBinaryLove(LALInferenceVariables *vars, REAL8 *lambda1, REAL8 *lambda2)
Compute Tidal deformabilities following BinaryLove Universal relations.
void LALInferenceCopyVariablesToArray(LALInferenceVariables *origin, REAL8 *target)
LALInference variables to an array, and vica versa.
void LALInferenceMcEta2Masses(double mc, double eta, double *m1, double *m2)
Convert from Mc, eta space to m1, m2 space (note m1 > m2).
ProcessParamsTable * LALInferenceGetProcParamVal(ProcessParamsTable *procparams, const char *name)
Returns the element of the process params table with "name".
INT4 LALInferenceFprintParameterNonFixedHeadersWithSuffix(FILE *out, LALInferenceVariables *params, const char *suffix)
Print the parameters which do not vary to a file as a tab-separated ASCII line, adding the given suff...
int LALInferenceWriteVariablesBinary(FILE *file, LALInferenceVariables *vars)
Write a LALInferenceVariables as binary to a given FILE pointer, returns the number of items written ...
void * LALInferenceGetVariable(const LALInferenceVariables *vars, const char *name)
Return a pointer to the memory the variable vars is stored in specified by name User must cast this p...
void XLALMultiNormalDeviates(REAL4Vector *vector, gsl_matrix *matrix, UINT4 dim, RandomParams *randParam)
Draw a random multivariate vector from Gaussian distr given covariance matrix.
int LALInferenceSplineCalibrationFactor(REAL8Vector *logfreqs, REAL8Vector *deltaAmps, REAL8Vector *deltaPhases, COMPLEX16FrequencySeries *calFactor)
Computes the factor relating the physical waveform to a measured waveform for a spline-fit calibratio...
INT4 LALInferenceSanityCheck(LALInferenceRunState *state)
Sanity check the structures in the given state.
void LALInferenceLogSampleToArray(LALInferenceVariables *algorithmParams, LALInferenceVariables *vars)
Append the sample to an array which can be later processed by the user.
void LALInferencePrintVariables(LALInferenceVariables *var)
output contents of a 'LALInferenceVariables' structure * / / * (by now only prints names and types,...
void LALInferenceExecuteInvFT(LALInferenceModel *model)
Execute Inverse FFT for data in IFOdata.
const CHAR * LALInferenceGetstringVariable(LALInferenceVariables *vars, const char *name)
LALInferenceVariables * LALInferenceReadVariablesBinary(FILE *stream)
Read from the given FILE * a LALInferenceVariables, which was previously written with LALInferenceWri...
void LALInferenceSetINT8Variable(LALInferenceVariables *vars, const char *name, INT8 value)
void LALInferenceSetREAL4Variable(LALInferenceVariables *vars, const char *name, REAL4 value)
int LALInferenceCheckVariable(LALInferenceVariables *vars, const char *name)
Checks for name being present in vars returns 1(==true) or 0.
void LALInferenceSetgslMatrixVariable(LALInferenceVariables *vars, const char *name, gsl_matrix *value)
void LALInferenceCopyUnsetREAL8Variables(LALInferenceVariables *origin, LALInferenceVariables *target, ProcessParamsTable *commandLine)
LALInferenceVariableItem * LALInferenceGetItemNr(LALInferenceVariables *vars, int idx)
Return the list node for the idx-th item - do not rely on this Indexing starts at 1.
void LALInferenceSetMCMCrunphase_ptrVariable(LALInferenceVariables *vars, const char *name, LALInferenceMCMCRunPhase *value)
void LALInferenceAddUINT4VectorVariable(LALInferenceVariables *vars, const char *name, UINT4Vector *value, LALInferenceParamVaryType vary)
void LALInferenceTranslateExternalToInternalParamName(char *outName, const char *inName)
Converts between externally used parameter names and those internal.
INT8 LALInferenceGetINT8Variable(LALInferenceVariables *vars, const char *name)
void LALInferenceSetCOMPLEX8Variable(LALInferenceVariables *vars, const char *name, COMPLEX8 value)
COMPLEX16 LALInferenceGetCOMPLEX16Variable(LALInferenceVariables *vars, const char *name)
LALInferenceVariableType
An enumerated type for denoting the type of a variable.
LALInferenceParamVaryType LALInferenceGetVariableVaryType(LALInferenceVariables *vars, const char *name)
Get the LALInferenceParamVaryType of the parameter named name in vars see the declaration of LALInfer...
char * LALInferencePrintCommandLine(ProcessParamsTable *procparams)
Output the command line based on the ProcessParamsTable procparams.
LALInferenceVariableItem * LALInferenceGetItem(const LALInferenceVariables *vars, const char *name)
Return the list node for "name" - do not rely on this.
void LALInferenceAddREAL4Variable(LALInferenceVariables *vars, const char *name, REAL4 value, LALInferenceParamVaryType vary)
void LALInferenceSetVariable(LALInferenceVariables *vars, const char *name, const void *value)
Set a variable named name in vars with a value.
void LALInferenceSetREAL8VectorVariable(LALInferenceVariables *vars, const char *name, REAL8Vector *value)
int LALInferenceCheckVariableNonFixed(LALInferenceVariables *vars, const char *name)
Checks for name being present in vars and having type LINEAR or CIRCULAR.
int LALInferenceReadRunStateBinary(FILE *file, LALInferenceRunState *runState)
Reads the file and populates LALInferenceVariables in the runState that were saved with LALInferenceR...
const char * LALInferenceTranslateInternalToExternalParamName(const char *inName)
Converts between internally used parameter names and those external (e.g.
void LALInferenceKDREAL8ToVariables(LALInferenceVariables *params, REAL8 *pt, LALInferenceVariables *templt)
Fills in the non-fixed variables in params from the given REAL8 array.
void LALInferenceAddCOMPLEX8Variable(LALInferenceVariables *vars, const char *name, COMPLEX8 value, LALInferenceParamVaryType vary)
@ LALINFERENCE_PARAM_OUTPUT
A parameter that never changes, functions should respect this.
@ LALINFERENCE_PARAM_FIXED
A parameter that is cyclic, such as an angle between 0 and 2pi.
@ LALINFERENCE_PARAM_CIRCULAR
A parameter that simply has a maximum and a minimum.
@ LALINFERENCE_PARAM_LINEAR
@ LALINFERENCE_COMPLEX16_t
@ LALINFERENCE_MCMCrunphase_ptr_t
@ LALINFERENCE_INT4Vector_t
@ LALINFERENCE_REAL8Vector_t
@ LALINFERENCE_void_ptr_t
@ LALINFERENCE_UINT4Vector_t
@ LALINFERENCE_gslMatrix_t
@ LALINFERENCE_COMPLEX8_t
@ LALINFERENCE_COMPLEX16Vector_t
void * XLALCalloc(size_t m, size_t n)
void * XLALMalloc(size_t n)
void * XLALRealloc(void *p, size_t n)
LALSimNeutronStarEOS * XLALSimNeutronStarEOSSpectralDecomposition(double gamma[], int size)
LALSimNeutronStarEOS * XLALSimNeutronStarEOS4ParameterPiecewisePolytrope(double logp1_si, double gamma1, double gamma2, double gamma3)
double XLALSimNeutronStarEOSPseudoEnthalpyOfPressure(double p, LALSimNeutronStarEOS *eos)
double XLALSimNeutronStarEOSSpeedOfSoundGeometerized(double h, LALSimNeutronStarEOS *eos)
double XLALSimNeutronStarEOSMaxPressure(LALSimNeutronStarEOS *eos)
void XLALDestroySimNeutronStarEOS(LALSimNeutronStarEOS *eos)
double XLALSimNeutronStarLoveNumberK2(double m, LALSimNeutronStarFamily *fam)
void XLALDestroySimNeutronStarFamily(LALSimNeutronStarFamily *fam)
double XLALSimNeutronStarRadius(double m, LALSimNeutronStarFamily *fam)
double XLALSimNeutronStarFamMinimumMass(LALSimNeutronStarFamily *fam)
double XLALSimNeutronStarCentralPressure(double m, LALSimNeutronStarFamily *fam)
LALSimNeutronStarFamily * XLALCreateSimNeutronStarFamily(LALSimNeutronStarEOS *eos)
double XLALSimNeutronStarMaximumMass(LALSimNeutronStarFamily *fam)
int XLALSimNeutronStarTOVODEIntegrate(double *radius, double *mass, double *love_number_k2, double central_pressure_si, LALSimNeutronStarEOS *eos)
size_t XLALStringCopy(char *dst, const char *src, size_t size)
char char * XLALStringDuplicate(const char *s)
int XLALNormalDeviates(REAL4Vector *deviates, RandomParams *params)
LALStringVector * XLALAppendString2Vector(LALStringVector *vect, const CHAR *string)
void XLALDestroyStringVector(LALStringVector *vect)
LALStringVector * XLALCreateEmptyStringVector(UINT4 length)
int XLALREAL8TimeFreqFFT(COMPLEX16FrequencySeries *freq, const REAL8TimeSeries *tser, const REAL8FFTPlan *plan)
int XLALREAL8FreqTimeFFT(REAL8TimeSeries *tser, const COMPLEX16FrequencySeries *freq, const REAL8FFTPlan *plan)
const LALUnit lalDimensionlessUnit
INT4Vector * XLALCreateINT4Vector(UINT4 length)
void XLALDestroyUINT4Vector(UINT4Vector *vector)
COMPLEX16Vector * XLALCreateCOMPLEX16Vector(UINT4 length)
void XLALDestroyREAL4Vector(REAL4Vector *vector)
UINT4Vector * XLALCreateUINT4Vector(UINT4 length)
void XLALDestroyINT4Vector(INT4Vector *vector)
REAL4Vector * XLALCreateREAL4Vector(UINT4 length)
REAL8Vector * XLALCreateREAL8Vector(UINT4 length)
void XLALDestroyREAL8Vector(REAL8Vector *vector)
void XLALDestroyCOMPLEX16Vector(COMPLEX16Vector *vector)
REAL8Vector * XLALDDVectorMultiply(REAL8Vector *out, const REAL8Vector *in1, const REAL8Vector *in2)
#define XLAL_ERROR_VOID(...)
#define XLAL_ERROR_REAL8(...)
#define XLAL_ERROR_NULL(...)
#define XLAL_PRINT_WARNING(...)
#define XLAL_TRY(statement, errnum)
int XLALPrintError(const char *fmt,...) _LAL_GCC_PRINTF_FORMAT_(1
int int XLALPrintWarning(const char *fmt,...) _LAL_GCC_PRINTF_FORMAT_(1
#define XLAL_ERROR_REAL4(...)
Structure to contain IFO data.
The kD trees in LALInference are composed of cells.
struct tagLALInferenceKDTree * right
Left (i.e.
int eigenFrameStale
Maximum coordinates of points in the eigen-frame.
REAL8 * eigenMax
Minimum coordinates of points in the eigen-frame.
REAL8 * upperRight
Lower left (i.e.
REAL8 ** ptsCovEigenVects
dim-by-dim covariance matrix.
size_t ptsSize
Stores the number of tree points that lie in the cell.
size_t dim
Size of the pts buffer.
REAL8 * lowerLeft
Mean of pts.
REAL8 ** pts
Dimension of the system.
struct tagLALInferenceKDTree * left
== 1 when the mean, covariance, and eigenvectors are out of date (i.e.
REAL8 * eigenMin
Eigenvectors of the covariance matrix: [i][j] is the jth component of the ith eigenvector.
REAL8 ** ptsCov
Upper right (i.e.
Structure to constain a model and its parameters.
REAL8FFTPlan * timeToFreqFFTPlan
Burst Waveform cache for LIB.
COMPLEX16FrequencySeries * freqhPlus
Time series model buffers.
REAL8TimeSeries * timehCross
REAL8TimeSeries * timehPlus
COMPLEX16FrequencySeries * freqhCross
REAL8FFTPlan * freqToTimeFFTPlan
INT4 freqLength
Sampling rate information.
REAL8Window * window
Pre-calculated FFT plans for forward and reverse FFTs.
Structure for holding a proposal cycle.
LALInferenceProposal ** proposals
INT4 nProposals
Length of cycle.
Structure containing inference run state This includes pointers to the function types required to run...
LALInferenceVariables * proposalArgs
The data from the interferometers.
LALInferenceVariables * algorithmParams
Any special arguments for the prior function.
INT4 nthreads
Array of live points for Nested Sampling.
struct tagLALInferenceIFOData * data
Log sample, i.e.
LALInferenceVariables * priorArgs
Common arguments needed by proposals, to be copied to thread->cycle.
LALInferenceThreadState * threads
Structure containing chain-specific variables.
LALInferenceVariables * proposedParams
Current location going into jump proposal.
LALInferenceVariables * algorithmParams
Arguments needed by proposals.
LALInferenceVariables * currentParams
Prior boundaries, etc.
LALInferenceVariables * priorArgs
Stope things such as output arrays.
REAL8 currentPropDensity
Stucture containing model buffers and parameters.
LALInferenceModel * model
Cycle of proposals to call.
size_t differentialPointsLength
Array of points for differential evolution.
LALInferenceVariables * proposalArgs
REAL8 temperature
Array containing multiple proposal densities.
INT4 * temp_swap_accepts
Pointer to the parent RunState of the thread.
size_t differentialPointsSize
Length of the current differential points stored in differentialPoints.
size_t differentialPointsSkip
Size of the differentialPoints memory block (must be >= length of differential points).
LALInferenceVariables ** differentialPoints
Parameters proposed.
LALInferenceVariables * preProposalParams
The current parameters.
The LALInferenceVariableItem list node structure This should only be accessed using the accessor func...
LALInferenceVariableType type
struct tagVariableItem * next
LALInferenceParamVaryType vary
The LALInferenceVariables structure to contain a set of parameters Implemented as a linked list of LA...
LALInferenceVariableItem * head
CHAR type[LIGOMETA_TYPE_MAX]
CHAR param[LIGOMETA_PARAM_MAX]
CHAR value[LIGOMETA_VALUE_MAX]
struct tagProcessParamsTable * next
CHAR program[LIGOMETA_PROGRAM_MAX]
LALInferenceVariableItem * itemPtr