vector - How to check if a matrix is upper-triangular in clojure -


i want write function compute upper triangular nature of matrix. lets a_i_j number in i^th row , j^th column. matrix upper-triangular if a_i_j = 0 > j.

try this:

(defn is-upper-triangular [m]   (->> (map-indexed vector m)        (mapcat (fn [[r v]] (take r v)))        (every? zero?))) 

the above code take 0 element first row, 1 element second row, , 2 elements third rows, etc... , checks taken elements zero. if zero, upper triangular.

this code not check given matrix square. can add check if necessary.


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -