From: Joseph M. Newcomer on 14 Jun 2010 16:35 See below... On Mon, 14 Jun 2010 20:58:47 +0200, Andreas Bauer wrote: >Hello Arne, >works well with C#. Maybe you have some hints with C++? *** If you have C# code, you probably can convert it to C++ in minutes. I fail to see why there is a problem if you have running code. If you have the code, you should post it here, and someone can probably spend the two or three minutes required to translate it for you. joe ****> > >I hope the last questions. >Why this way? This way is correct, I'm sure. >StepsToAxis<=> UserCoordinatesInMM >fx = a*x + b*y + c >and not the simplest way >fx = a*x + b > >How is call in mathematics? > Both 'Linear Regression' ? > >How looks the calculation, if y not depend from x. >Can you make an example? Maybe, I hope then is clear for me, to see the >differents. > >How is the best way to Round? Which function? > int stepsToAxisXInteger = Convert.ToInt32(stepsToAxisX); > int stepsToAxisXInteger = Convert.ToInt32(stepsToAxisX + 0.5); > >I can calculate this way, it is easy > stepsToAxisX = b[0] * userX + b[1] * userY + b[2]; >If I want to use the matrix >How is here the best way? Can you make a simple example? >For example, I have 10 new values, I know the factors b[0] b[1] b[2]; > 10 > 20 > 30 > 40 > 50 >... > 100 > >User in MM ---- Black Box ----- Steps to axis, axis move > > >Picture, calculate by hand. >http://www1.minpic.de/bild_anzeigen.php?id=114769&key=72372343&ende > >Excel sheet > See sheet - Three Variables are not know >http://www.fileuploadx.de/665288 > >Greeting Andreas > > > >http://www.mathdotnet.com/downloads/Iridium-2008-8-16-470.ashx > >fx = 0,639237208990945*x + 0,0326366299017556*y + 19,8200049707945 >fy = 0,00341428308423573*x + -0,646872751008385*y + 273,495238414032 > >fx = a*x + b*y + c > > using MathNet.Numerics.LinearAlgebra; // Assembly notwendig. > private void btnCalc_Click(object sender, EventArgs e) > { > double[] fx = { 130.816, 196.860, 113.987 }; > double[] fy = { 266.000, 256.000, 175.000 }; > double[] x = { 173.0, 275.5, 139.5 }; > double[] y = { 12.5, 28.5, 153}; > > double[] b; > Solve(fx, out b, x, y); > Console.WriteLine("fx = " + b[0] + "*x + " + b[1] + "*y + " >+ b[2]); > // Steps to axis x > double userX = 40.4; > double userY = 90.5; > double stepsToAxisX = b[0] * userX + b[1] * userY + b[2]; > userX = 173.0; > userY = 12.5; > stepsToAxisX = b[0] * userX + b[1] * userY + b[2]; > int stepsToAxisXInteger = Convert.ToInt32(stepsToAxisX); > > Solve(fy, out b, x, y); > Console.WriteLine("fy = " + b[0] + "*x + " + b[1] + "*y + " >+ b[2]); > //Console.ReadKey(); > > > } > > private static void Solve(double[] f, out double[] b, double[] >x, double[] y) > { > Vector one = Vector.Ones(x.Length); > Vector x2 = Vector.Create(x); > Vector y2 = Vector.Create(y); > Matrix xy3 = Matrix.CreateFromColumns(new List { >x2, y2, one }); > Vector f2 = Vector.Create(f); > Matrix f3 = Matrix.CreateFromColumns(new List { f2 }); > Matrix b3 = xy3.Solve(f3); > Vector b2 = b3.GetColumnVector(0); > b = b2.CopyToArray(); > } Joseph M. Newcomer [MVP] email: newcomer(a)flounder.com Web: http://www.flounder.com MVP Tips: http://www.flounder.com/mvp_tips.htm From: Oliver Regenfelder on 16 Jun 2010 06:21 Hello, Joseph M. Newcomer wrote:> See below... > On Mon, 14 Jun 2010 20:58:47 +0200, Andreas Bauer wrote: > >> Hello Arne, >> works well with C#. Maybe you have some hints with C++? > *** > If you have C# code, you probably can convert it to C++ in minutes. > > I fail to see why there is a problem if you have running code. > > If you have the code, you should post it here, and someone can probably spend the two or > three minutes required to translate it for you. To be honest, the whole thing sounds a lot like a school/university assignment to me. Best regards, Oliver From: Joseph M. Newcomer on 16 Jun 2010 10:10 See below... On Wed, 16 Jun 2010 12:21:30 +0200, Oliver Regenfelder wrote: >Hello, > >Joseph M. Newcomer wrote: >> See below... >> On Mon, 14 Jun 2010 20:58:47 +0200, Andreas Bauer wrote: >> >>> Hello Arne, >>> works well with C#. Maybe you have some hints with C++? >> *** >> If you have C# code, you probably can convert it to C++ in minutes. >> >> I fail to see why there is a problem if you have running code. >> >> If you have the code, you should post it here, and someone can probably spend the two or >> three minutes required to translate it for you. > >To be honest, the whole thing sounds a lot like a school/university assignment to me. > >Best regards, > >Oliver **** It might be. No one but an undergrad or a consulting client could ask such an ill-formed question and expect a useful answer! The question doesn't make sense, the several restatements make less sense, there is no specification of what is to be done, no specification of the encoding to be used, no specification of the communication mechanism, no specification of the goal, and when I get a client like this, it usually takes me a day to extract from them (and this is often done on-site) all the specifications of the problem. Ultimately, I spend more of my time teaching people how to ask questions than answering them. joe **** Joseph M. Newcomer [MVP] email: newcomer(a)flounder.com Web: http://www.flounder.com MVP Tips: http://www.flounder.com/mvp_tips.htm From: Hans-J. Ude on 16 Jun 2010 10:43 Joseph M. Newcomer schrieb: >The question doesn't make sense, the several restatements make less sense, there is no >specification of what is to be done, no specification of the encoding to be used, no >specification of the communication mechanism, no specification of the goal, and when I get >a client like this, it usually takes me a day to extract from them (and this is often done >on-site) all the specifications of the problem. Maybe he's trolling around with that. I've seen that subject from that guy at so many places, even myself told him what everybody tells him, don't care about. Hans From: Joseph M. Newcomer on 16 Jun 2010 16:11 He may be trolling because he is desperate. The problem is, he doesn't know how to ask a question. So the answer is not going to happen. Until he can formulate a sane and comprehensible question for which an answer can be given, no answer will ever happen. I don't care how desperate he is; the whole problem statement is at best totally incoherent. And I don't think that the issue is related to English as a Second Language. If this person is not a native English speaker, the question would be equally ill-formed and incomprehensible if asked in the OP's native tongue to a native speaker of the language. Perhaps he can answer my questions: (1) my program doesn't work, what did I do wrong? (2) I have a bunch of numbers I have to send out, and I don't know how to do it. What should I do? (3) Why doesn't the value show properly? joe On Wed, 16 Jun 2010 16:43:36 +0200, Hans-J. Ude wrote: >Joseph M. Newcomer schrieb: > >>The question doesn't make sense, the several restatements make less sense, there is no >>specification of what is to be done, no specification of the encoding to be used, no >>specification of the communication mechanism, no specification of the goal, and when I get >>a client like this, it usually takes me a day to extract from them (and this is often done >>on-site) all the specifications of the problem. > >Maybe he's trolling around with that. I've seen that subject from that >guy at so many places, even myself told him what everybody tells him, >don't care about. > >Hans Joseph M. Newcomer [MVP] email: newcomer(a)flounder.com Web: http://www.flounder.com MVP Tips: http://www.flounder.com/mvp_tips.htm