2

I need to solve a linear system with Eigen for linear regression. Normally to compute the constant coefficient it is assumed that the data has an additional column, composed fully of 1s. Then the solve() can compute it correctly.

I was wondering whether there is a way to avoid having all these ones explicitly, at no additional runtime costs. For example by appending a constant vector to the data matrix or in some other way. Wen dealing with large amounts of data that would save some space and memory loads.

Svalorzen
  • 5,353
  • 3
  • 30
  • 54
  • You could maybe use concatenation: https://stackoverflow.com/a/68747925/11770674 and combine it with a nullary expression, i.e. `Ones`. But it does introduce conditional statements in the code, so I'm not sure about the runtime cost. – RL-S Nov 03 '21 at 09:28

0 Answers0