File: mlgsl_sort.c

package info (click to toggle)
ocamlgsl 0.6.0-3
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 4,024 kB
  • ctags: 3,091
  • sloc: ml: 8,539; ansic: 7,338; makefile: 262; sh: 150; awk: 13
file content (71 lines) | stat: -rw-r--r-- 1,646 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/* ocamlgsl - OCaml interface to GSL                        */
/* Copyright (©) 2005 - Olivier Andrieu                     */
/* distributed under the terms of the GPL version 2         */

#include <caml/fail.h>
#include <caml/memory.h>
#include <caml/callback.h>
#include <caml/bigarray.h>

#include <gsl/gsl_sort_vector.h>

#include "wrappers.h"
#include "mlgsl_vector_double.h"
#include "mlgsl_permut.h"

CAMLprim value
ml_gsl_sort_vector (value v)
{
  _DECLARE_VECTOR(v);
  _CONVERT_VECTOR(v);
  gsl_sort_vector (&v_v);
  return Val_unit;
}

CAMLprim value
ml_gsl_sort_vector_index (value p, value v)
{
  GSL_PERMUT_OF_BIGARRAY(p);
  _DECLARE_VECTOR(v);
  _CONVERT_VECTOR(v);
  gsl_sort_vector_index (&perm_p, &v_v);
  return Val_unit;
}

CAMLprim value
ml_gsl_sort_vector_smallest (value dest, value v)
{
  _DECLARE_VECTOR(v);
  _CONVERT_VECTOR(v);
  gsl_sort_vector_smallest (Double_array_val (dest), Double_array_length (dest), &v_v);
  return Val_unit;
}

CAMLprim value
ml_gsl_sort_vector_largest (value dest, value v)
{
  _DECLARE_VECTOR(v);
  _CONVERT_VECTOR(v);
  gsl_sort_vector_largest (Double_array_val (dest), Double_array_length (dest), &v_v);
  return Val_unit;
}

CAMLprim value
ml_gsl_sort_vector_smallest_index (value p, value v)
{
  GSL_PERMUT_OF_BIGARRAY(p);
  _DECLARE_VECTOR(v);
  _CONVERT_VECTOR(v);
  gsl_sort_vector_smallest_index (perm_p.data, perm_p.size, &v_v);
  return Val_unit;
}

CAMLprim value
ml_gsl_sort_vector_largest_index (value p, value v)
{
  GSL_PERMUT_OF_BIGARRAY(p);
  _DECLARE_VECTOR(v);
  _CONVERT_VECTOR(v);
  gsl_sort_vector_largest_index (perm_p.data, perm_p.size, &v_v);
  return Val_unit;
}