Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
alta
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
5
Issues
5
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
alta
alta
Commits
39f7f4a7
Commit
39f7f4a7
authored
Nov 05, 2013
by
Laurent Belcour
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixing the Matlab interpolator to handle domain boundary.
parent
f519aa73
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
1 deletion
+16
-1
sources/plugins/data_interpolant_matlab/data.cpp
sources/plugins/data_interpolant_matlab/data.cpp
+16
-1
No files found.
sources/plugins/data_interpolant_matlab/data.cpp
View file @
39f7f4a7
...
...
@@ -123,7 +123,7 @@ vec data_interpolant::value(vec ax) const
// Evaluate the matlab routine
std
::
stringstream
cmd
;
cmd
<<
"y = griddatan(X(:, 1:"
<<
dimX
()
<<
"), Y(:, 1), x);"
;
cmd
<<
"y = griddatan(X(:, 1:"
<<
dimX
()
<<
"), Y(:, 1), x
, 'linear'
);"
;
engEvalString
(
ep
,
cmd
.
str
().
c_str
());
// Get results and copy it
...
...
@@ -131,6 +131,21 @@ vec data_interpolant::value(vec ax) const
double
*
y_val
=
(
double
*
)
mxGetData
(
y
);
memcpy
(
&
res
[
0
],
y_val
,
dimY
()
*
sizeof
(
double
));
// Fail safe: if the query point is outside of the convex hull of the
// 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
());
// Get results and copy it
y
=
engGetVariable
(
ep
,
"y"
)
;
double
*
y_val
=
(
double
*
)
mxGetData
(
y
);
memcpy
(
&
res
[
0
],
y_val
,
dimY
()
*
sizeof
(
double
));
}
return
res
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment