In Julia, suppose I have a matrix A, and I would like to know the number of diagonal entries that are smaller than some threshold value. One way to do this is to initialize a new array of diagonal entries of A with diag(), and then use the count function to count how many are below some threshold value.
A_diag=(diag(A))
count(<(0.1), A_diag)
But, I prefer not to initialize any new arrays (as I did with the diag function). Is there any way in Julia to check how many diagonal entries of a matrix satisfy some condition, without initializing any NEW arrays?