Skip to main content
added 8 characters in body
Source Link
flawr
  • 43.9k
  • 7
  • 104
  • 249

MATL, 18 15 1510 bytes

llZ(GlZ)Y\

Basically a straight translation fromworks the same as my Octave program. Thanks for -5 bytes @LuisMendo! This improvement was achieved by inputting the ones directly into the input instead of deleting a column and concatenating another one as well as some reordering of the steps.

1Z)t0^G4LZ)hwY\

Explanation

1Z)ll            push extracttwo theones firstfor column
later use in tthe next line
  Z(        duplicate first column
 implicitly take the 0^input and plug in all ONES in to the FIRST generatecolumn a 
 vector of ones of appropriateGl length
      G4LZ) push input again, push geta theone remainingfor columnsuse fromin the input
next line
      Z)    h  get the concatenateFIRST itcolumn withof the vector ofinput onesmatrix
        Y\    wY\ multiply firstthis column with the pseudo inverse of the matrix wefrom justthe constructedbeginnign

Try it online!Try it online!

MATL, 18 15 bytes

Basically a straight translation from my Octave program.

1Z)t0^G4LZ)hwY\

Explanation

1Z)             extract the first column
   t            duplicate first column
    0^          generate a vector of ones of appropriate length
      G4LZ)     get the remaining columns from the input
           h    concatenate it with the vector of ones
            wY\ multiply first column with pseudo inverse of the matrix we just constructed

Try it online!

MATL, 18 15 10 bytes

llZ(GlZ)Y\

Basically works the same as my Octave program. Thanks for -5 bytes @LuisMendo! This improvement was achieved by inputting the ones directly into the input instead of deleting a column and concatenating another one as well as some reordering of the steps.

Explanation

ll            push two ones for later use in the next line
  Z(          implicitly take the input and plug in all ONES in to the FIRST column  
    Gl        push input again, push a one for use in the next line
      Z)      get the FIRST column of the input matrix
        Y\    multiply this column with the pseudo inverse of the matrix from the beginnign

Try it online!

added 399 characters in body
Source Link
flawr
  • 43.9k
  • 7
  • 104
  • 249

MATL, 18 15 bytes

Basically a straight translation from my Octave program.

1Z)t0^G4LZ)hwY\

Explanation

1Z)             extract the first column
   t            duplicate first column
    0^          generate a vector of ones of appropriate length
      G4LZ)     get the remaining columns from the input
           h    concatenate it with the vector of ones
            wY\ multiply first column with pseudo inverse of the matrix we just constructed

Try it online!

MATL, 18 15 bytes

Basically a straight translation from my Octave program.

1Z)t0^G4LZ)hwY\

Try it online!

MATL, 18 15 bytes

Basically a straight translation from my Octave program.

1Z)t0^G4LZ)hwY\

Explanation

1Z)             extract the first column
   t            duplicate first column
    0^          generate a vector of ones of appropriate length
      G4LZ)     get the remaining columns from the input
           h    concatenate it with the vector of ones
            wY\ multiply first column with pseudo inverse of the matrix we just constructed

Try it online!

Source Link
flawr
  • 43.9k
  • 7
  • 104
  • 249

MATL, 18 15 bytes

Basically a straight translation from my Octave program.

1Z)t0^G4LZ)hwY\

Try it online!