Sum rows of a matrix to create new array


#1

Is there a way to sum all elements in a row of a matrix and output a new single column array?

For ex. if I have a matrix:

1 0 1 1
0 0 0 0
0 1 1 0

I want to sum each row to output a new array:

3
0
2

And then I want to use the maximum() function to give me the max value in the array = 3


#2

This is a pretty simple question… The documentation for sum explicitly answers it.

  Sum elements of an array over the given dimensions.

     Examples
    ≡≡≡≡≡≡≡≡≡≡

  julia> A = [1 2; 3 4]
  2×2 Array{Int64,2}:
   1  2
   3  4

  julia> sum(A, 1)
  1×2 Array{Int64,2}:
   4  6

  julia> sum(A, 2)
  2×1 Array{Int64,2}:
   3
   7

#3

In Julia 0.7,

using Random
srand(0)
obj = rand(4, 4)
maximum(sum(obj, dims = 2))