Bonsoir à tous,

je travaille avec des Bigarray et j'ai un problème de type pour cette fonction :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
method addSampleFromBigarrayAndLetter ba letter =
         self#addSample (self#bigarrayToArray ba) (self#getArrayFromChar letter)
ou ba est un bigArray rempli de SINT8 (des char en C) et letter est un char.
bigarrayToArray renvoie un tableau de float de même que getArrayFromChar.

Voici ce que me donne la compilation (passage intéressants) :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
File "network.ml", line 17, characters 5-10077:
Some type variables are unbound in this type:
  class nNetwork :
    int ->
    int ->
    int ->
    object
      [...]
      method addSampleFromBigarrayAndLetter :
        (int, 'a, 'b) Bigarray.Array1.t -> char -> unit
      method private bigarrayToArray :
        (int, 'a, 'b) Bigarray.Array1.t -> float array
      [...]
      method private getArrayFromChar : char -> float array
      [...]
    end
The method addSampleFromBigarrayAndLetter has type
  (int, 'a, 'b) Bigarray.Array1.t -> char -> unit
where 'b is unbound
make[1]: *** [network.cmx] Erreur 2
Et là ça plante la compilation. J'ai essayé de forcer le type comme ceci :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
method addSampleFromBigarrayAndLetter (ba:int -> Bigarray.int8_signed_elt -> Bigarray.int8_signed_elt) letter =
         self#addSample (self#bigarrayToArray ba) (self#getArrayFromChar letter)
mais ça ne fonctionne pas non plus :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
File "network.ml", line 196, characters 39-41:
This expression has type
  int -> Bigarray.int8_signed_elt -> Bigarray.int8_signed_elt
but is here used with type (int, 'a, 'b) Bigarray.Array1.t
make[1]: *** [network.cmx] Erreur 2
D'avance merci de m'éclairer

Cya

Tangui