gsl-ocaml / examples / permut_ex.ml

open Bigarray
open Gsl

let _ = 
  Error.init () ;
  Random.self_init ()

let print_arr arr = 
  Array.iter (fun i -> Printf.printf "% 4d " i) arr ;
  print_newline ()

let print_barr arr = 
  for i=0 to pred (Array1.dim arr) do
    Printf.printf "% 4d " arr.{i}
  done ;
  print_newline ()

let _ = 
  let p = Permut.make 5 in
  Permut.next p ;
  print_string "permut :" ; print_arr (Permut.to_array p) ;
  let a = Array.init 5 (fun _ -> Random.int 10) in
  print_string "arr :" ; print_arr a ;
  Permut.permute p a ;
  print_string "arr :" ; print_arr a ;
  
  let a1 = Array1.of_array int c_layout a in
  print_string "arr1 :" ; print_barr a1 ;
  Permut.permute_barr p a1 ;
  print_string "arr1 :" ; print_barr a1
  
    
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.