Method: CsrMatrix::Helpers#max_col

Defined in:
lib/csrmatrix/helpers.rb

#max_col(array) ⇒ Object

ARRAY FUNCTIONS for pre-processing of matrix



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/csrmatrix/helpers.rb', line 9

def max_col(array)
	# Identifies the 'column' value of an array (eg. the number of entries in a column)
	# pre 	array
	# post 	column count of array
	values = array
	max_count = 0
	# Loop over indexes.
	values.each_index do |i|
		counter = 0
	  # Get subarray and loop over its indexes also.
	  subarray = values[i]
	  subarray.each_index do |x|
	  	counter += 1
	  end
	  if counter > max_count
	  	max_count = counter
	  end
	end
	return max_count
end