I am new to Julia and this is the first time I ever ask for help in a forum, so please let me know if I can improve my post.
My problem:
Let dR and dW be functions from R^2 → R^{n \times n}.
There exists a pair (i,j) such that dR(i,j) < \epsilon and dW(i,j)< \epsilon.
Goal: find (i,j)
Hence I want to run a loop like
while dR(i,j) .> 0.01 || dW(i,j).> 0.01 do something until there is (i,j) such that dR(i,j) < 0.01 AND dW(i,j) < 0.01
However, I get the following ERROR: TypeError: non-boolean (BitMatrix) used in boolean context
When you say dR(i, j), do you mean the function dR evaluated at the point (i, j), or the number located at index ij in the n \times n matrix that is returned by dR?.
@screw_dog is correct with some options that might get rid of the error message, but the core issue is that this logic is currently ambiguous. What does it mean for a matrix to be less than a number?
thank you very much for your response and advices! I did not know about the any and all functions, so thank you for that too.
Does while any(dR(i,j) .> 0.01) || any(dW(i,j) .> 0.01)
mean as long as there are any elements for which dR(i,j) > 0.01 or dW(i,j) >0.01 holds, the loop runs? If it is so, it is not what I am alooking for, because there will always be elements for which this conditions holds. Hence I need all right? But that resulted in the following error: ERROR: MethodError: no method matching (::var"#16#20")(::Matrix{Float64})
I mean dR evalutatet at the point (i,j) which coincides with the location ij.
I don`t want the matrix to be less than a scalar, I am looking for an element in the matrix, i.e. the point at which the evaluation of dR and dW is less than any \epsilon. I hope I made myself clear now.
Thank you for any further ideas.
Let A be some m\times n matrix. The statement A < epsilon is undefined because you’re trying to compare a matrix to a scalar. The dot you used (.<) is for broadcasting and indicates that you want this comparison to run for every element. So, A .< epsilon returns a new matrix of Boolean values indicating whether the corresponding elements in matrix A satisfied the condition.
If you only want to check a particular element you can use index notation: A[i, j] returns the element at index ij.
If you want to check all of the elements and then reduce those results with some extras logic, you can also do that. The any and all functions are examples of reductions.