How create new array which subtracts values from 2 double arrays in C#?
Posted
by
Tomek eM
on Stack Overflow
See other posts from Stack Overflow
or by Tomek eM
Published on 2014-06-11T10:10:21Z
Indexed on
2014/06/11
15:25 UTC
Read the original article
Hit count: 205
Helou it's my problem, I have 2 array which have double values:
(this is function which get back values(latitude) from richTextBox)
private Tuple<double>[] szerokosc(string[] lines)
{
return Array.ConvertAll(lines, line =>
{
string[] elems = line.Split(',');
double we = 0.01 * double.Parse(elems[3], EnglishCulture);
int stopnie = (int)we;
double minuty = ((we - stopnie) * 100) / 60;
double szerokosc_dziesietna = stopnie + minuty;
return new Tuple<double>(Math.Round(szerokosc_dziesietna, (int)numericUpDown2.Value));
});
;
}
(this part of code call function)
var data1 = szerokosc(szerdlugeo_diag_gps.Lines);
var data2 = szerokosc(szerdlugeo_diag_gpsglonass.Lines);
What should I do, to get something like this:
for example: var data3 = data1 - data2;
My values in this data looks like (f.e.) data1 = (x11, x12, ... x1(n) ):
53.11818160073043,
53.11816348903661,
53.11814874695463,
...
data2 = (x21, x22, ... x(2n) ):
53.11814200771546,
53.118131477652156,
53.11812263239697,
53.11811884157276,
53.11811631435644,
....
I would like back data3 = (x31=x11-x21, x32=x12=x22, ... x(3n)=x(1n)-x(2n) )
It would be good if it included the following condition: if data1 = ( 1, 5, 6, 8) data2 = (1.5, 3.3)
data3 = (-0.5, 1.7) not data3 = (-0.5, 1.7, 6, 8)
Please help.
© Stack Overflow or respective owner