gsl-ocaml / lib / mlgsl_sort.c

Markus Mottl c8ec844 
Markus Mottl b6d7484 
Markus Mottl a685ddc 
Markus Mottl b6d7484 

































































/* gsl-ocaml - OCaml interface to GSL                       */
/* Copyright (©) 2005 - Olivier Andrieu                     */
/* Distributed under the terms of the GPL version 3         */

#include <caml/fail.h>
#include <caml/memory.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;
}
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.