lua-matrix icon indicating copy to clipboard operation
lua-matrix copied to clipboard

matrix({1,2,3,4}) doesn't work

Open Egor-Skriptunoff opened this issue 6 years ago • 1 comments

For some very strange reason, vector-to-matrix constructor doesn't work for vectors having more than 3 elements.
Tail elements of the vector (starting with the 4-th) are silently rejected by the current matrix:new() implementation.

Egor-Skriptunoff avatar Jan 04 '19 10:01 Egor-Skriptunoff

hey, there is an easy fix. after line 124 in lua_matrix.lua, replace the next line (line 125) with

  local mtx = {}
  for i=1,#rows do
      mtx[i] = {rows[i]}
  end
  return setmetatable( mtx, matrix_meta )

also you can write matrix{1,2,3,4...} for short

bachp2 avatar Jun 23 '19 02:06 bachp2