@josevalim, as per our discussion, added a function that can add a row to a matrix one at a time, similar to Python's list based append. Since this is a standalone functionality that can be used irrespective of the CSV loading function we are going to implement, I thought of pushing it separately. Also, this operation is fast, since old data is maintained and we just "push back" the new row at the end after reallocation of memory.
Incorrect usage (having more than one row, or lower/higher number of columns than the original matrix) will raise:
iex(5)> mat = Tensorflex.append_to_matrix(mat, [[1,2]])
** (ArgumentError) data columns must be same as matrix and number of rows must be 1
(tensorflex) lib/tensorflex.ex:46: Tensorflex.append_to_matrix/2
iex(5)> mat = Tensorflex.append_to_matrix(mat, [[1,1,1,1],[2,2,2,2]])
** (ArgumentError) data columns must be same as matrix and number of rows must be 1
(tensorflex) lib/tensorflex.ex:46: Tensorflex.append_to_matrix/2
@josevalim, as per our discussion, added a function that can add a row to a matrix one at a time, similar to Python's list based
append
. Since this is a standalone functionality that can be used irrespective of the CSV loading function we are going to implement, I thought of pushing it separately. Also, this operation is fast, since old data is maintained and we just "push back" the new row at the end after reallocation of memory.Some basic usage:
Incorrect usage (having more than one row, or lower/higher number of columns than the original matrix) will
raise
: