+ |N i1 -> string_of_int i1
+ |R f1 -> string_of_float f1
+ |Vec vec ->
+ let basics : basic array =
+ Array.init vec#size vec#nth in
+ let strings = Array.to_list
+ (Array.map basic_to_string basics) in
+ String.concat "," strings
+ |Zero -> "0"
+ |Error -> "0";;
+
+let basic_of_float : float -> basic = fun f -> R f;;
+
+let rec basic_of_float_array : float array -> basic =
+ fun (data : float array) ->
+ let n = Array.length data in
+ if n = 0 then
+ raise (Convert_Error "basic_of_float_array : empty.")
+ else if n = 1 then basic_of_float data.(0)
+ else
+ let vec = Array.get (Array.map basic_of_float data) in
+ Vec (new vector n vec);;