Skip to content

Commit

Permalink
length(a::AbstractArray) = numel(a). Closes Issue #156.
Browse files Browse the repository at this point in the history
  • Loading branch information
ViralBShah committed Jul 31, 2011
1 parent 36bcbf4 commit cd643c0
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions j/tensor.j
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ typealias Region Union(Size,Dims)
size(t::AbstractArray, d) = size(t)[d]
ndims{T,n}(::AbstractArray{T,n}) = n
numel(t::AbstractArray) = prod(size(t))
length(v::AbstractVector) = numel(v)
length(t::AbstractArray) = error("length not defined for ", typeof(t))
length(a::AbstractArray) = numel(a)
nnz(a::AbstractArray) = (n = 0; for i=1:numel(a); n += a[i] != 0 ? 1 : 0; end; n)
nnz(a::AbstractArray{Bool}) = (n = 0; for i=1:numel(a); n += a[i] == true ? 1 : 0; end; n)

Expand Down

0 comments on commit cd643c0

Please sign in to comment.