I have written mathematica file that does manipulations on a certain set of points. I would like to access code that someone else has written for a least square fit in C++. How do I access this C++ in mathematica?
Some specifics about the code: The least square fit code is a function that accesses a .cpp file and two different .h files. It is a void function that takes in a vector of points, the point itself, and an integer, each called by reference.
I make this specific because I am a novice in coding in c++. I have seen in another post someone say that they have :
I think we have these:
MathLink communication through pipes/files LibraryLink
I do not have any of those things, nor do I know what they are. Can someone explain how a novice like myself can handle this situation.
Also, from what I saw from other posts, the function I have to access is much more complicated. It looks something like:
void function1(vectorFoo &thing, Foo &variable1, int64_t &variable2) {
stuff happens here
}
(the the first argument of the function is a vector that takes in Foo between "<" and ">" but that formatting won't let me show that. that's why I wrote "vectorFoo")
this function accesses other functions,call them "function2", "function3", and other named variables (if that is the right technical term...like I said, I don't know much c++) from three files. so even if I call this file, will I have to worry about calling the other three files from which it draws? Please help!
ptsfinds the circle parameters for you:NMinimize[{((#1 - mx)^2 + (#2 - my)^2 - r^2)^2 & @@@ pts // Total, mx > 0 && my > 0 && r > 0}, {mx, my, r}]– Sjoerd C. de Vries Jul 07 '15 at 14:38points = {{x1,y1},{x2,y2},{x3,y3},...}
then I should write
NMinimize[{((#1 - points[[i]][[1]])^2 + (#2 - points[[i]][[2]])^2 - r^2)^2 & @@@ pts // Total, points[[i]][[1]] > 0 && points[[i]][[2]] > 0 && r > 0}, {points[[i]][[1]], points[[i]][[2]], r}]
What do I put for #1, #2, and r, given that I only have a list of points?
– nycguy92 Jul 07 '15 at 20:16ptsto your list of points before running @Sjoerd's snippet. – J. M.'s missing motivation Jul 08 '15 at 02:47pts ={{1,0},{0.7,0.71}, ... ,{-1,0}}or whatever your data may be. Then execute the above code as is. The result will be the circle's center given bymxandmyand its radiusr. – Sjoerd C. de Vries Jul 08 '15 at 05:55ptsin my code to the one you're using (apparently,points). That's the only change needed in that case. – Sjoerd C. de Vries Jul 08 '15 at 06:05