Commit e46817ed authored by PACANOWSKI Romain's avatar PACANOWSKI Romain

Merge

parents 4a5bfb30 06a67801
......@@ -9,8 +9,8 @@
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="293.85605"
height="261.828"
width="293.8457"
height="293.85001"
id="svg2"
version="1.1"
inkscape:version="0.48.3.1 r9886"
......@@ -25,8 +25,8 @@
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="1.979899"
inkscape:cx="173.41891"
inkscape:cy="194.35337"
inkscape:cx="174.41936"
inkscape:cy="194.34737"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
......@@ -55,33 +55,34 @@
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(-218.71772,-239.02595)">
transform="translate(-218.72743,-206.99795)">
<path
style="fill:none;stroke:#ff0000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
d="m 224.12391,254.21248 c 13.75014,-24.3849 62.57976,-16.29367 92.34189,16.27477 29.76214,32.56845 41.1261,57.06917 49.22092,57.06917 8.09481,0 17.17249,-24.19853 45.31129,-54.32841 26.28078,-28.14042 71.92956,-44.49114 92.03679,-23.6903 22.68832,23.47096 -2.73331,74.43857 -42.23404,105.40769 -39.50073,30.96911 -94.75983,42.27522 -94.75983,42.27522 0,0 -46.47766,-5.96811 -85.35167,-34.05434 -38.87401,-28.08623 -73.46513,-78.9832 -56.56535,-108.9538 z"
d="m 224.12391,242.21248 c 13.75014,-24.3849 62.57976,-16.29367 92.34189,16.27477 29.76214,32.56845 41.1261,57.06917 49.22092,57.06917 8.09481,0 17.17249,-24.19853 45.31129,-54.32841 26.28078,-28.14042 71.92956,-44.49114 92.03679,-23.6903 22.68832,23.47096 -2.73331,74.43857 -42.23404,105.40769 -39.50073,30.96911 -94.75983,42.27522 -94.75983,42.27522 0,0 -46.47766,-5.96811 -85.35167,-34.05434 -38.87401,-28.08623 -73.46513,-78.9832 -56.56535,-108.9538 z"
id="path3913-2"
inkscape:connector-curvature="0"
sodipodi:nodetypes="sssssscss" />
<path
style="fill:none;stroke:#ff4545;stroke-width:1.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
d="m 236.62391,264.21248 c 14.17834,-20.33759 44.92431,-11.01902 78.41332,17.70334 32.97641,28.28274 41.84037,66.71203 49.93519,66.71203 8.09481,0 20.62643,-41.92398 51.73987,-68.97127 29.49506,-25.64042 57.46035,-35.7403 75.25107,-18.33316 15.56867,15.233 8.69527,49.43857 -31.8769,88.26484 -36.26388,34.70337 -94.86629,48.01117 -94.86629,48.01117 0,0 -41.01405,-7.77549 -79.88805,-35.86172 -38.87401,-28.08623 -66.12206,-72.54659 -48.70821,-97.52523 z"
d="m 236.62391,252.21248 c 14.17834,-20.33759 44.92431,-11.01902 78.41332,17.70334 32.97641,28.28274 41.84037,66.71203 49.93519,66.71203 8.09481,0 20.62643,-41.92398 51.73987,-68.97127 29.49506,-25.64042 57.46035,-35.7403 75.25107,-18.33316 15.56867,15.233 8.69527,49.43857 -31.8769,88.26484 -36.26388,34.70337 -94.86629,48.01117 -94.86629,48.01117 0,0 -41.01405,-7.77549 -79.88805,-35.86172 -38.87401,-28.08623 -66.12206,-72.54659 -48.70821,-97.52523 z"
id="path3913-2-2"
inkscape:connector-curvature="0"
sodipodi:nodetypes="sssssscss" />
<path
style="fill:none;stroke:#ffa5a5;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 252.14286,281.6479 c 11.22313,-19.90344 48.45526,-7.76059 72.74769,18.82241 24.29244,26.58301 33.85944,65.82044 40.46659,65.82044 6.60714,0 14.59953,-36.36721 37.56697,-60.95981 21.45089,-22.96876 56.37826,-44.76824 72.79018,-27.79019 18.51865,19.15746 -4.27153,57.26013 -36.5128,82.53773 -32.24127,25.2776 -73.93364,37.73013 -73.93364,37.73013 0,0 -34.6425,-9.8446 -66.37223,-32.76913 -31.72973,-22.92453 -60.54669,-58.92899 -46.75276,-83.39158 z"
d="m 252.14286,269.6479 c 11.22313,-19.90344 48.45526,-7.76059 72.74769,18.82241 24.29244,26.58301 33.85944,65.82044 40.46659,65.82044 6.60714,0 14.59953,-36.36721 37.56697,-60.95981 21.45089,-22.96876 56.37826,-44.76824 72.79018,-27.79019 18.51865,19.15746 -4.27153,57.26013 -36.5128,82.53773 -32.24127,25.2776 -73.93364,37.73013 -73.93364,37.73013 0,0 -34.6425,-9.8446 -66.37223,-32.76913 -31.72973,-22.92453 -60.54669,-58.92899 -46.75276,-83.39158 z"
id="path3913"
inkscape:connector-curvature="0"
sodipodi:nodetypes="sssssscss" />
<path
style="fill:none;stroke:#ffcece;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 281.25,307.18361 c 9.89568,-9.23073 28.95137,-3.81082 42.92626,11.67956 15.01774,16.64632 37.2523,68.67758 41.53802,68.67758 4.64286,0 11.68203,-37.64965 36.85269,-63.63838 10.82971,-11.18168 34.18545,-27.81335 46.71875,-17.61162 4.52996,3.68725 8.40704,28.6887 -26.15566,57.00202 -31.69261,25.96217 -57.86221,34.51584 -57.86221,34.51584 0,0 -34.10679,-16.45174 -56.37223,-34.91199 C 278.76114,337.91217 276.12533,311.96393 281.25,307.18361 z"
d="m 281.25,295.18361 c 9.89568,-9.23073 28.95137,-3.81082 42.92626,11.67956 15.01774,16.64632 37.2523,68.67758 41.53802,68.67758 4.64286,0 11.68203,-37.64965 36.85269,-63.63838 10.82971,-11.18168 34.18545,-27.81335 46.71875,-17.61162 4.52996,3.68725 8.40704,28.6887 -26.15566,57.00202 -31.69261,25.96217 -57.86221,34.51584 -57.86221,34.51584 0,0 -34.10679,-16.45174 -56.37223,-34.91199 C 278.76114,325.91217 276.12533,299.96393 281.25,295.18361 z"
id="path3913-4"
inkscape:connector-curvature="0"
sodipodi:nodetypes="sssssscss" />
<g
id="g4237">
id="g4237"
transform="translate(0,-12)">
<path
sodipodi:nodetypes="sssss"
inkscape:connector-curvature="0"
......@@ -109,12 +110,12 @@
</g>
<path
style="fill:none;stroke:#0014ff;stroke-width:1.5;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
d="m 338.17413,466.67792 c 26.23203,-27.2526 28.51432,-67.74954 27.03189,-69.17645 -1.58831,-1.52883 -41.81995,2.43989 -68.05199,29.6925 -26.23204,27.25261 -38.31464,58.18399 -26.98725,69.08719 11.32737,10.90318 41.7753,-2.35062 68.00735,-29.60324 z"
d="m 338.17413,454.67792 c 26.23203,-27.2526 28.51432,-67.74954 27.03189,-69.17645 -1.58831,-1.52883 -41.81995,2.43989 -68.05199,29.6925 -26.23204,27.25261 -38.31464,58.18399 -26.98725,69.08719 11.32737,10.90318 41.7753,-2.35062 68.00735,-29.60324 z"
id="path3061-2-9"
inkscape:connector-curvature="0"
sodipodi:nodetypes="sssss" />
<g
transform="matrix(-1,0,0,1,731.52215,0.17647029)"
transform="matrix(-1,0,0,1,731.52215,-11.82353)"
id="g4237-4">
<path
sodipodi:nodetypes="sssss"
......@@ -143,67 +144,67 @@
</g>
<path
style="fill:none;stroke:#737eff;stroke-width:1.5846529;stroke-miterlimit:4;stroke-opacity:1;stroke-dashoffset:0"
d="m 347.2917,443.9146 c 17.76341,-18.4545 19.27866,-45.81714 18.27482,-46.7834 -1.07555,-1.03527 -28.28878,1.59175 -46.05219,20.04625 -17.76342,18.45451 -25.94531,39.40016 -18.2748,46.78341 7.67048,7.38324 28.28875,-1.59175 46.05217,-20.04626 z"
d="m 347.2917,431.9146 c 17.76341,-18.4545 19.27866,-45.81714 18.27482,-46.7834 -1.07555,-1.03527 -28.28878,1.59175 -46.05219,20.04625 -17.76342,18.45451 -25.94531,39.40016 -18.2748,46.78341 7.67048,7.38324 28.28875,-1.59175 46.05217,-20.04626 z"
id="path3061-3-2-0"
inkscape:connector-curvature="0"
sodipodi:nodetypes="sssss" />
<path
style="fill:none;stroke:#0014ff;stroke-width:1.5;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
d="m 393.58256,466.56803 c -26.23203,-27.2526 -28.46968,-67.66025 -26.98725,-69.08716 1.58831,-1.52883 41.77531,2.3506 68.00735,29.60321 26.23204,27.25261 38.31464,58.18399 26.98725,69.08719 -11.32737,10.90318 -41.7753,-2.35062 -68.00735,-29.60324 z"
d="m 393.58256,454.56803 c -26.23203,-27.2526 -28.46968,-67.66025 -26.98725,-69.08716 1.58831,-1.52883 41.77531,2.3506 68.00735,29.60321 26.23204,27.25261 38.31464,58.18399 26.98725,69.08719 -11.32737,10.90318 -41.7753,-2.35062 -68.00735,-29.60324 z"
id="path3061-2"
inkscape:connector-curvature="0"
sodipodi:nodetypes="sssss" />
<path
style="fill:none;stroke:#737eff;stroke-width:1.5846529;stroke-miterlimit:4;stroke-opacity:1;stroke-dashoffset:0"
d="m 384.39803,444.05025 c -17.76341,-18.4545 -19.27866,-45.81714 -18.27482,-46.7834 1.07555,-1.03527 28.28878,1.59175 46.05219,20.04625 17.76342,18.45451 25.94531,39.40016 18.2748,46.78341 -7.67048,7.38324 -28.28875,-1.59175 -46.05217,-20.04626 z"
d="m 384.39803,432.05025 c -17.76341,-18.4545 -19.27866,-45.81714 -18.27482,-46.7834 1.07555,-1.03527 28.28878,1.59175 46.05219,20.04625 17.76342,18.45451 25.94531,39.40016 18.2748,46.78341 -7.67048,7.38324 -28.28875,-1.59175 -46.05217,-20.04626 z"
id="path3061-3-2"
inkscape:connector-curvature="0"
sodipodi:nodetypes="sssss" />
<path
style="fill:none;stroke:#0014ff;stroke-width:1.51787508;stroke-miterlimit:4;stroke-opacity:1;stroke-dashoffset:0"
d="m 381.30553,343.48876 c 0,29.20938 -14.38907,52.88825 -15.51011,52.88825 -1.20111,0 -15.51012,-23.67887 -15.51012,-52.88825 0,-29.20939 6.94412,-52.88826 15.51012,-52.88826 8.56599,0 15.51011,23.67887 15.51011,52.88826 z"
d="m 381.30553,331.48876 c 0,29.20938 -14.38907,52.88825 -15.51011,52.88825 -1.20111,0 -15.51012,-23.67887 -15.51012,-52.88825 0,-29.20939 6.94412,-52.88826 15.51012,-52.88826 8.56599,0 15.51011,23.67887 15.51011,52.88826 z"
id="path3061"
inkscape:connector-curvature="0"
sodipodi:nodetypes="sssss" />
<path
style="fill:none;stroke:#737eff;stroke-width:1.02785146;stroke-miterlimit:4;stroke-opacity:1;stroke-dashoffset:0"
d="m 376.30439,361.12469 c 0,19.77956 -9.74377,35.81406 -10.5029,35.81406 -0.81335,0 -10.50291,-16.0345 -10.50291,-35.81406 0,-19.77957 4.70232,-35.81406 10.50291,-35.81406 5.80058,0 10.5029,16.03449 10.5029,35.81406 z"
d="m 376.30439,349.12469 c 0,19.77956 -9.74377,35.81406 -10.5029,35.81406 -0.81335,0 -10.50291,-16.0345 -10.50291,-35.81406 0,-19.77957 4.70232,-35.81406 10.50291,-35.81406 5.80058,0 10.5029,16.03449 10.5029,35.81406 z"
id="path3061-3"
inkscape:connector-curvature="0"
sodipodi:nodetypes="sssss" />
<path
style="fill:none;stroke:#afb5ff;stroke-width:1.18082547;stroke-miterlimit:4;stroke-opacity:1;stroke-dashoffset:0"
d="m 349.47045,433.04801 c 14.17692,-14.72848 16.70508,-35.29707 16.00666,-35.96933 -0.74831,-0.7203 -21.1556,2.63872 -35.33252,17.36719 -14.17693,14.72849 -21.34333,30.83251 -16.00665,35.96935 5.33667,5.13682 21.15559,-2.63873 35.33251,-17.36721 z"
d="m 349.47045,421.04801 c 14.17692,-14.72848 16.70508,-35.29707 16.00666,-35.96933 -0.74831,-0.7203 -21.1556,2.63872 -35.33252,17.36719 -14.17693,14.72849 -21.34333,30.83251 -16.00665,35.96935 5.33667,5.13682 21.15559,-2.63873 35.33251,-17.36721 z"
id="path3061-3-5-7-2"
inkscape:connector-curvature="0"
sodipodi:nodetypes="sssss" />
<path
style="fill:none;stroke:#afb5ff;stroke-width:1.18082547;stroke-miterlimit:4;stroke-opacity:1;stroke-dashoffset:0"
d="m 382.28625,433.25062 c -14.17692,-14.72848 -16.70508,-35.29707 -16.00666,-35.96933 0.74831,-0.7203 21.1556,2.63872 35.33252,17.36719 14.17693,14.72849 21.34333,30.83251 16.00665,35.96935 -5.33667,5.13682 -21.15559,-2.63873 -35.33251,-17.36721 z"
d="m 382.28625,421.25062 c -14.17692,-14.72848 -16.70508,-35.29707 -16.00666,-35.96933 0.74831,-0.7203 21.1556,2.63872 35.33252,17.36719 14.17693,14.72849 21.34333,30.83251 16.00665,35.96935 -5.33667,5.13682 -21.15559,-2.63873 -35.33251,-17.36721 z"
id="path3061-3-5-7"
inkscape:connector-curvature="0"
sodipodi:nodetypes="sssss" />
<path
style="fill:none;stroke:#afb5ff;stroke-width:0.76591736;stroke-miterlimit:4;stroke-opacity:1;stroke-dashoffset:0"
d="m 373.1018,368.22061 c 0,15.786 -6.77914,28.58309 -7.3073,28.58309 -0.56589,0 -7.30731,-12.79709 -7.30731,-28.58309 0,-15.78601 3.2716,-28.58309 7.30731,-28.58309 4.0357,0 7.3073,12.79708 7.3073,28.58309 z"
d="m 373.1018,356.22061 c 0,15.786 -6.77914,28.58309 -7.3073,28.58309 -0.56589,0 -7.30731,-12.79709 -7.30731,-28.58309 0,-15.78601 3.2716,-28.58309 7.30731,-28.58309 4.0357,0 7.3073,12.79708 7.3073,28.58309 z"
id="path3061-3-5"
inkscape:connector-curvature="0"
sodipodi:nodetypes="sssss" />
<path
style="fill:none;stroke:#cdd1ff;stroke-width:0.79749054;stroke-miterlimit:4;stroke-opacity:1;stroke-dashoffset:0"
d="m 379.89815,423.17982 c -10.71797,-11.13495 -13.99811,-25.36757 -13.57674,-25.77316 0.45147,-0.43456 14.51851,3.41511 25.23648,14.55007 10.71796,11.13495 16.79646,22.67398 13.57671,25.77316 -3.21974,3.09916 -14.51848,-3.41511 -25.23645,-14.55007 z"
d="m 379.89815,411.17982 c -10.71797,-11.13495 -13.99811,-25.36757 -13.57674,-25.77316 0.45147,-0.43456 14.51851,3.41511 25.23648,14.55007 10.71796,11.13495 16.79646,22.67398 13.57671,25.77316 -3.21974,3.09916 -14.51848,-3.41511 -25.23645,-14.55007 z"
id="path3061-3-5-9-0"
inkscape:connector-curvature="0"
sodipodi:nodetypes="sssss" />
<path
style="fill:none;stroke:#cdd1ff;stroke-width:0.51727533;stroke-miterlimit:4;stroke-opacity:1;stroke-dashoffset:0"
d="m 370.21015,375.08395 c 0,11.93446 -4.09001,21.60925 -4.40866,21.60925 -0.34141,0 -4.40867,-9.67479 -4.40867,-21.60925 0,-11.93446 1.97383,-21.60924 4.40867,-21.60924 2.43483,0 4.40866,9.67478 4.40866,21.60924 z"
d="m 370.21015,363.08395 c 0,11.93446 -4.09001,21.60925 -4.40866,21.60925 -0.34141,0 -4.40867,-9.67479 -4.40867,-21.60925 0,-11.93446 1.97383,-21.60924 4.40867,-21.60924 2.43483,0 4.40866,9.67478 4.40866,21.60924 z"
id="path3061-3-5-9"
inkscape:connector-curvature="0"
sodipodi:nodetypes="sssss" />
<path
style="fill:none;stroke:#cdd1ff;stroke-width:0.79749054;stroke-miterlimit:4;stroke-opacity:1;stroke-dashoffset:0"
d="m 351.76926,423.13346 c 10.71797,-11.13495 13.99811,-25.36757 13.57674,-25.77316 -0.45147,-0.43456 -14.51851,3.41511 -25.23648,14.55007 -10.71796,11.13495 -16.79646,22.67398 -13.57671,25.77316 3.21974,3.09916 14.51848,-3.41511 25.23645,-14.55007 z"
d="m 351.76926,411.13346 c 10.71797,-11.13495 13.99811,-25.36757 13.57674,-25.77316 -0.45147,-0.43456 -14.51851,3.41511 -25.23648,14.55007 -10.71796,11.13495 -16.79646,22.67398 -13.57671,25.77316 3.21974,3.09916 14.51848,-3.41511 25.23645,-14.55007 z"
id="path3061-3-5-9-0-5"
inkscape:connector-curvature="0"
sodipodi:nodetypes="sssss" />
......
......@@ -60,18 +60,21 @@ void data_interpolant::load(const std::string& filename)
{
vec x = _data->get(i);
// For a point extract all its coordinates
for(int j=0; j<dimX(); ++j)
{
eX(i, j) = x[j];
}
// Extract all its values
for(int k=0; k<dimY(); ++k)
{
for(int j=0; j<dimX(); ++j)
{
eX(i, j + k*dimX()) = x[j];
}
eY(i, k) = x[dimX() + k];
}
}
// Create matrices
X = mxCreateDoubleMatrix(_data->size(), dimX()*dimY(), mxREAL);
X = mxCreateDoubleMatrix(_data->size(), dimX(), mxREAL);
memcpy((void *)mxGetPr(X), (void *) eX.data(), _data->size()*dimY()*dimX()*sizeof(double));
engPutVariable(ep, "X", X);
......@@ -121,11 +124,30 @@ vec data_interpolant::value(vec ax) const
memcpy((void *)mxGetPr(x), (void *)&ax[0], dimX()*sizeof(double));
engPutVariable(ep, "x", x);
// Evaluate the matlab routine
std::stringstream cmd;
cmd << "y = griddatan(X(:, 1:" << dimX() <<"), Y(:, 1), x, 'linear');";
engEvalString(ep, cmd.str().c_str());
// Iterate over the output dimension
for(int i=0; i<dimY(); ++i)
{
// Evaluate the matlab routine
if(dimX() == 2)
{
cmd << "y(" << i+1 << ") = griddata(X(:,1), X(:,2), Y(:," << i+1 << "), x(1), x(2), 'cubic');";
}
else if(dimX() == 3)
{
cmd << "y(" << i+1 << ") = griddata(X(:,1), X(:,2), X(:,3), Y(:," << i+1 << "), x(1), x(2), x(3), 'cubic');";
}
else
{
cmd << "y(" << i+1 << ") = griddatan(X(:, 1:" << dimX() <<"), Y(:, " << i+1 << "), x, 'linear');";
}
engEvalString(ep, cmd.str().c_str());
#ifdef DEBUG
std::cout << output;
#endif
}
// Get results and copy it
y = engGetVariable(ep, "y") ;
double* y_val = (double*)mxGetData(y);
......@@ -135,11 +157,12 @@ vec data_interpolant::value(vec ax) const
// data, rerun the algorithm using a nearest option.
if(isnan(res[0]))
{
cmd.str(std::string());
cmd << "y = griddatan(X(:, 1:" << dimX() <<"), Y(:, 1), x, 'nearest');";
engEvalString(ep, cmd.str().c_str());
for(int i=0; i<dimY(); ++i)
{
cmd.str(std::string());
cmd << "y("<< i+1 <<") = griddatan(X(:, 1:" << dimX() <<"), Y(:, " << i+1 << "), x, 'nearest');";
engEvalString(ep, cmd.str().c_str());
}
// Get results and copy it
y = engGetVariable(ep, "y") ;
double* y_val = (double*)mxGetData(y);
......
......@@ -68,17 +68,28 @@ int main(int argc, char** argv)
#ifndef OLD
// Number of elements per dimension
const vec dim = args.get_vec("dim", nX, 100.0);
assert(dim.size() == nX);
std::vector<int> dim;
if(args.is_defined("dim"))
{
dim = args.get_vec<int>("dim");
assert(dim.size() == nX);
}
else
{
for(int i=0; i<nX; ++i)
{
dim.push_back(100);
}
}
// Compute the volume in which we integrate and then compute the
// dt to apply for each element.
double dt = 1.0;
int nb = 0;
int nb = 1;
for(int k=0; k<nX; ++k)
{
dt *= d->max()[k] - d->min()[k];
nb += int(dim[k]);
nb *= dim[k];
}
dt /= double(nb);
......@@ -101,8 +112,8 @@ int main(int argc, char** argv)
int global = i;
for(int k=0; k<nX; ++k)
{
indices[k] = global % int(dim[k]);
global /= int(dim[k]);
indices[k] = global % dim[k];
global /= dim[k];
}
vec x(nX);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment