mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2025-01-01 09:49:45 +00:00
fast sum for matrices too
This commit is contained in:
parent
5faecd6e79
commit
9f249d9cf3
1 changed files with 1 additions and 1 deletions
|
@ -585,7 +585,7 @@ function lcm(a,b=[]) =
|
|||
function sum(v, dflt=0) =
|
||||
v==[]? dflt :
|
||||
assert(is_consistent(v), "Input to sum is non-numeric or inconsistent")
|
||||
is_vector(v) ? [for(i=[1:len(v)]) 1]*v :
|
||||
is_vector(v) || is_matrix(v) ? [for(i=[1:len(v)]) 1]*v :
|
||||
_sum(v,v[0]*0);
|
||||
|
||||
function _sum(v,_total,_i=0) = _i>=len(v) ? _total : _sum(v,_total+v[_i], _i+1);
|
||||
|
|
Loading…
Reference in a new issue