Skip to content

Instantly share code, notes, and snippets.

@ryanrhymes
Last active May 2, 2017 23:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanrhymes/022151ae7d1b8c94363f509532df7a29 to your computer and use it in GitHub Desktop.
Save ryanrhymes/022151ae7d1b8c94363f509532df7a29 to your computer and use it in GitHub Desktop.
reply to boolean indexing ...
```ocaml
Mat.map (min 5.) x;;
```
```ocaml
let x = Mat.uniform 5 5;;
Mat.filter (( < ) 0.5) x;;
...
```
```ocaml
open Owl.Ext;;
let x = Dense.Matrix.D.uniform 5 5;;
let y = x >. F 0.5;;
```
`y` is a `0`/`1` matrix which has the same meaning of a boolean matrix. For a similar example to the one you gave before, `a[a>0.5] = 5`, you can simply write
```ocaml
max2 x (x >. F 0.5) * F 5.;;
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment