Method: CsrMatrix::Helpers#count_nonzero

Defined in:
lib/csrmatrix/helpers.rb

#count_nonzero(array) ⇒ Object

max_row



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/csrmatrix/helpers.rb', line 42

def count_nonzero(array) 
	# Finds all nonzero values in an array.
	# pre 	array 
	# post 	int nonzero count of array
	max_count = 0
	array.each_index do |i|
		subarray = array[i]
	  subarray.each_index do |x|
	  	if array[i][x] != 0
	  		max_count += 1
	  	end
	  end
	end
	return max_count
end