### Calculating number arrays from a text file.

I wish to create a program in C++ that can conduct a linear regression calculation on an array of numbers.

e.g. Text File

33 46 60 42 96
66 38 80 37 51
21 29 43 46 5
44 82 38 50 97
17 6 2 72 84
97 59 24 97 90
43 55 66 19 52
55 83 3 94 47
87 58 90 87 11
67 69 35 65 34
15 22 48 81 84
16 76 24 80 45
3 27 8 100 73
43 32 86 52 67
57 100 16 13 84
56 36 12 73 88
56 83 96 30 96
66 96 97 8 3
48 89 76 4 78
80 66 16 63 46

I would intend for the file to have more observations than this; each row may have hundreds to thousands of numbers. For the first row, I would calculate y = a+bx for the first row of numbers, then calculate it again for the second, etc, and the output would show the linear regression equation for each row.

Can somebody also tell me how one would calculate a row in isolation? e.g. if I had this text file but only wanted to do calculations on the fifth row down for example, how would I do this?

Many thanks
Use list or vector of vectors

The list will store vector of integers. Each row will have a separate vector for it
Read the number into the vector. Do calculations on the numbers.

You can have another vector to store row-wise results.

For calculating for nth row
1) you can read till nth row and then calculate, this is inefficient
OR
2) Skip n-1 rows read only nth row and then do the calculations
Topic archived. No new replies allowed.