123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554# 1 "src/base/compute/owl_computation_operator_sig.ml"(*
* OWL - OCaml Scientific Computing
* Copyright (c) 2016-2022 Liang Wang <liang@ocaml.xyz>
*)openOwl_types(* Functor of making the symbols of a computation graph. *)moduletypeSig=sigmoduleSymbol:Owl_computation_symbol_sig.SigopenSymbol.Shape.Type(** {5 Vectorised functions} *)valnoop:arr->arr(**
[noop arr] performs no operation on the array [arr] and returns it as is.
This can be useful as a placeholder function.
Returns the input array [arr].
*)valempty:intarray->arr(**
[empty shape] creates an uninitialized array with the specified [shape].
The contents of the array are undefined.
Returns a new array with the given shape.
*)valzeros:intarray->arr(**
[zeros shape] creates an array with the specified [shape], filled with zeros.
Returns a new array with all elements initialized to zero.
*)valones:intarray->arr(**
[ones shape] creates an array with the specified [shape], filled with ones.
Returns a new array with all elements initialized to one.
*)valcreate:intarray->elt->arr(**
[create shape value] creates an array with the specified [shape], filled with the given [value].
Returns a new array with all elements initialized to [value].
*)valsequential:?a:elt->?step:elt->intarray->arr(**
[sequential ?a ?step shape] creates an array with the specified [shape], filled with a sequence of values starting from [a] with a step of [step].
If [a] is not provided, the sequence starts from 0.
If [step] is not provided, the step size is 1.
Returns a new array with sequential values.
*)valuniform:?a:elt->?b:elt->intarray->arr(**
[uniform ?a ?b shape] creates an array with the specified [shape], filled with random values drawn from a uniform distribution over \[a, b\).
If [a] and [b] are not provided, the default range is \[0, 1\) .
Returns a new array with uniform random values.
*)valgaussian:?mu:elt->?sigma:elt->intarray->arr(**
[gaussian ?mu ?sigma shape] creates an array with the specified [shape], filled with random values drawn from a Gaussian distribution with mean [mu] and standard deviation [sigma].
If [mu] is not provided, the default mean is 0.
If [sigma] is not provided, the default standard deviation is 1.
Returns a new array with Gaussian random values.
*)valbernoulli:?p:elt->intarray->arr(**
[bernoulli ?p shape] creates an array with the specified [shape], filled with random values drawn from a Bernoulli distribution with probability [p] of being 1.
If [p] is not provided, the default probability is 0.5.
Returns a new array with Bernoulli random values.
*)valinit:intarray->(int->elt)->arr(**
[init shape f] creates an array with the specified [shape], where each element is initialized using the function [f].
The function [f] takes the linear index of the element as input.
Returns a new array with elements initialized by the function [f].
*)valinit_nd:intarray->(intarray->elt)->arr(**
[init_nd shape f] creates an array with the specified [shape], where each element is initialized using the function [f].
The function [f] takes the multidimensional index of the element as input.
Returns a new array with elements initialized by the function [f].
*)valshape:arr->intarray(**
[shape arr] returns the shape of the array [arr] as an array of integers, each representing the size of the corresponding dimension.
*)valnumel:arr->int(**
[numel arr] returns the total number of elements in the array [arr].
*)valget:arr->intarray->elt(**
[get arr index] retrieves the element at the specified multidimensional [index] in the array [arr].
Returns the value of the element at the given index.
*)valset:arr->intarray->elt->unit(**
[set arr index value] sets the element at the specified multidimensional [index] in the array [arr] to the given [value].
*)valget_slice:intlistlist->arr->arr(**
[get_slice slices arr] extracts a slice from the array [arr] according to the list of [slices].
Each element in [slices] specifies the range for the corresponding dimension.
Returns a new array with the extracted slice.
*)valset_slice:intlistlist->arr->arr->unit(**
[set_slice slices src dest] sets the slice in [dest] defined by [slices] with the values from the source array [src].
*)valget_fancy:indexlist->arr->arr(**
[get_fancy indices arr] extracts elements from the array [arr] according to the list of [indices].
Each element in [indices] specifies an advanced indexing method.
Returns a new array with the extracted elements.
*)valset_fancy:indexlist->arr->arr->unit(**
[set_fancy indices src dest] sets the elements in [dest] defined by [indices] with the values from the source array [src].
*)valcopy:arr->arr(**
[copy arr] creates a deep copy of the array [arr].
Returns a new array that is a copy of [arr].
*)valcopy_:out:'a->'b->'c(**
[copy_ ~out src] copies the contents of the array [src] into the pre-allocated array [out].
*)valreset:arr->unit(**
[reset arr] sets all elements of the array [arr] to zero.
*)valreshape:arr->intarray->arr(**
[reshape arr shape] reshapes the array [arr] into the new [shape].
The total number of elements must remain the same.
Returns a new array with the specified shape.
*)valreverse:arr->arr(**
[reverse arr] reverses the elements of the array [arr] along each dimension.
Returns a new array with the elements reversed.
*)valtile:arr->intarray->arr(**
[tile arr reps] replicates the array [arr] according to the number of repetitions specified in [reps] for each dimension.
Returns a new array with the tiled data.
*)valrepeat:arr->intarray->arr(**
[repeat arr reps] repeats the elements of the array [arr] according to the number of repetitions specified in [reps] for each dimension.
Returns a new array with the repeated data.
*)valpad:?v:elt->intlistlist->arr->arr(**
[pad ?v padding arr] pads the array [arr] with the value [v] according to the [padding] specification for each dimension.
If [v] is not provided, the default padding value is zero.
Returns a new array with the padded data.
*)valexpand:?hi:bool->arr->int->arr(**
[expand ?hi arr n] expands the dimensions of the array [arr] by inserting a new dimension of size [n].
If [hi] is true, the new dimension is added at the beginning; otherwise, it is added at the end.
Returns a new array with the expanded dimensions.
*)valsqueeze:?axis:intarray->arr->arr(**
[squeeze ?axis arr] removes single-dimensional entries from the shape of the array [arr].
If [axis] is provided, only the specified dimensions are removed.
Returns a new array with the squeezed shape.
*)valconcatenate:?axis:int->arrarray->arr(**
[concatenate ?axis arrays] concatenates a sequence of arrays along the specified [axis].
If [axis] is not provided, the arrays are concatenated along the first axis.
Returns a new array with the concatenated data.
*)valstack:?axis:int->arrarray->arr(**
[stack ?axis arrays] stacks a sequence of arrays along a new dimension at the specified [axis].
If [axis] is not provided, the arrays are stacked along the first axis.
Returns a new array with the stacked data.
*)valconcat:axis:int->arr->arr->arr(**
[concat ~axis a b] concatenates the arrays [a] and [b] along the specified [axis].
Returns a new array with the concatenated data.
*)valsplit:?axis:int->'a->'b->'c(**
[split ?axis src num_or_sections] splits the array [src] into multiple sub-arrays along the specified [axis].
- [num_or_sections] specifies the number of equal-sized sub-arrays or the indices where to split.
Returns an array of sub-arrays.
*)valdraw:?axis:int->arr->int->arr*'aarray(**
[draw ?axis arr n] randomly draws [n] samples from the array [arr] along the specified [axis].
Returns a tuple containing the sampled array and an array of indices from which the samples were drawn.
*)valmap:(elt->elt)->arr->arr(**
[map f arr] applies the function [f] to each element of the array [arr].
Returns a new array with the results of applying [f].
*)valfold:?axis:int->(elt->elt->elt)->elt->arr->arr(**
[fold ?axis f init arr] reduces the array [arr] along the specified [axis] using the function [f] and an initial value [init].
If [axis] is not provided, the reduction is performed on all elements.
Returns a new array with the reduced values.
*)valscan:?axis:int->(elt->elt->elt)->arr->arr(**
[scan ?axis f arr] performs a cumulative reduction of the array [arr] along the specified [axis] using the function [f].
Returns a new array with the cumulative results.
*)valone_hot:int->arr->arr(**
[one_hot depth arr] converts the array [arr] into a one-hot encoded array with a specified [depth].
Returns a new array with one-hot encoding.
*)valdelay:(Device.A.arr->Device.A.arr)->arr->arr(**
[delay f x] returns [f x]. It allows to use a function that is not tracked
by the computation graph and delay its evaluation. The output must have the
same shape as the input.
*)valdelay_array:intarray->(Device.A.arrarray->Device.A.arr)->arrarray->arr(**
[delay_array out_shape f x] works in the same way as [delay] but is applied
on an array of ndarrays. Needs the shape of the output as an argument.
*)vallazy_print:?max_row:int->?max_col:int->?header:bool->?fmt:(Device.A.elt->string)->arr->arr(**
[lazy_print x] prints the output of [x] when it is evaluated. Is implemented
as an identity node. For information about the optional parameters, refer to the
[print] function of the [Ndarray] module.
*)valprint:?max_row:'a->?max_col:'b->?header:'c->?fmt:'d->'e->unit(**
[print ?max_row ?max_col ?header ?fmt data] prints a representation of the given [data].
- [max_row] is an optional parameter specifying the maximum number of rows to print.
- [max_col] is an optional parameter specifying the maximum number of columns to print.
- [header] is an optional parameter to include a header in the output.
- [fmt] is an optional parameter to specify the format of the output.
*)valabs:arr->arr(**
[abs arr] computes the absolute value of each element in the array [arr].
Returns a new array with the absolute values.
*)valneg:arr->arr(**
[neg arr] negates each element in the array [arr].
Returns a new array with each element negated.
*)valfloor:arr->arr(**
[floor arr] applies the floor function to each element in the array [arr].
Returns a new array with the floor of each element.
*)valceil:arr->arr(**
[ceil arr] applies the ceiling function to each element in the array [arr].
Returns a new array with the ceiling of each element.
*)valround:arr->arr(**
[round arr] rounds each element in the array [arr] to the nearest integer.
Returns a new array with each element rounded to the nearest integer.
*)valsqr:arr->arr(**
[sqr arr] computes the square of each element in the array [arr].
Returns a new array with the square of each element.
*)valsqrt:arr->arr(**
[sqrt arr] computes the square root of each element in the array [arr].
Returns a new array with the square roots of the elements.
*)vallog:arr->arr(**
[log arr] computes the natural logarithm of each element in the array [arr].
Returns a new array with the natural logarithms of the elements.
*)vallog2:arr->arr(**
[log2 arr] computes the base-2 logarithm of each element in the array [arr].
Returns a new array with the base-2 logarithms of the elements.
*)vallog10:arr->arr(**
[log10 arr] computes the base-10 logarithm of each element in the array [arr].
Returns a new array with the base-10 logarithms of the elements.
*)valexp:arr->arr(**
[exp arr] computes the exponential function of each element in the array [arr].
Returns a new array with the exponentials of the elements.
*)valsin:arr->arr(**
[sin arr] computes the sine of each element in the array [arr].
Returns a new array with the sines of the elements.
*)valcos:arr->arr(**
[cos arr] computes the cosine of each element in the array [arr].
Returns a new array with the cosines of the elements.
*)valtan:arr->arr(**
[tan arr] computes the tangent of each element in the array [arr].
Returns a new array with the tangents of the elements.
*)valsinh:arr->arr(**
[sinh arr] computes the hyperbolic sine of each element in the array [arr].
Returns a new array with the hyperbolic sines of the elements.
*)valcosh:arr->arr(**
[cosh arr] computes the hyperbolic cosine of each element in the array [arr].
Returns a new array with the hyperbolic cosines of the elements.
*)valtanh:arr->arr(**
[tanh arr] computes the hyperbolic tangent of each element in the array [arr].
Returns a new array with the hyperbolic tangents of the elements.
*)valasin:arr->arr(**
[asin arr] computes the arcsine of each element in the array [arr].
Returns a new array with the arcsines of the elements.
*)valacos:arr->arr(**
[acos arr] computes the arccosine of each element in the array [arr].
Returns a new array with the arccosines of the elements.
*)valatan:arr->arr(**
[atan arr] computes the arctangent of each element in the array [arr].
Returns a new array with the arctangents of the elements.
*)valasinh:arr->arr(**
[asinh arr] computes the inverse hyperbolic sine of each element in the array [arr].
Returns a new array with the inverse hyperbolic sines of the elements.
*)valacosh:arr->arr(**
[acosh arr] computes the inverse hyperbolic cosine of each element in the array [arr].
Returns a new array with the inverse hyperbolic cosines of the elements.
*)valatanh:arr->arr(**
[atanh arr] computes the inverse hyperbolic tangent of each element in the array [arr].
Returns a new array with the inverse hyperbolic tangents of the elements.
*)valmin:?axis:int->?keep_dims:bool->arr->arr(**
[min ?axis ?keep_dims arr] computes the minimum value along the specified axis of the array [arr].
- [axis] specifies the axis along which to compute the minimum.
- [keep_dims] specifies whether to keep the reduced dimensions.
Returns a new array with the minimum values.
*)valmax:?axis:int->?keep_dims:bool->arr->arr(**
[max ?axis ?keep_dims arr] computes the maximum value along the specified axis of the array [arr].
- [axis] specifies the axis along which to compute the maximum.
- [keep_dims] specifies whether to keep the reduced dimensions.
Returns a new array with the maximum values.
*)valsum:?axis:int->?keep_dims:bool->arr->arr(**
[sum ?axis ?keep_dims arr] computes the sum of elements along the specified axis of the array [arr].
- [axis] specifies the axis along which to compute the sum.
- [keep_dims] specifies whether to keep the reduced dimensions.
Returns a new array with the sum of elements.
*)valsum_reduce:?axis:intarray->arr->arr(**
[sum_reduce ?axis arr] computes the sum of elements along the specified axes of the array [arr].
- [axis] specifies the axes along which to compute the sum.
Returns a new array with the sum of elements.
*)valsignum:arr->arr(**
[signum arr] computes the signum function of each element in the array [arr].
Returns a new array where each element is -1, 0, or 1, depending on the sign of the corresponding element in [arr].
*)valsigmoid:arr->arr(**
[sigmoid arr] computes the sigmoid function of each element in the array [arr].
Returns a new array with the sigmoid values.
*)valrelu:arr->arr(**
[relu arr] applies the Rectified Linear Unit (ReLU) function to each element in the array [arr].
Returns a new array where each element is the maximum of 0 and the corresponding element in [arr].
*)valdawsn:arr->arr(**
[dawsn arr] computes Dawson's function of each element in the array [arr].
Returns a new array with Dawson's function values.
*)valmin':arr->elt(**
[min' arr] computes the minimum value in the array [arr].
Returns the minimum value as an element.
*)valmax':arr->elt(**
[max' arr] computes the maximum value in the array [arr].
Returns the maximum value as an element.
*)valsum':arr->elt(**
[sum' arr] computes the sum of all elements in the array [arr].
Returns the sum as an element.
*)vallog_sum_exp':arr->elt(**
[log_sum_exp' arr] computes the log-sum-exp of all elements in the array [arr].
Returns the log-sum-exp as an element.
*)vallog_sum_exp:?axis:int->?keep_dims:bool->arr->arr(**
[log_sum_exp ?axis ?keep_dims arr] computes the log of the sum of exponentials of elements along the specified [axis] of the array [arr].
- [axis] specifies the axis along which to compute the log-sum-exp. If not specified, computes over all elements.
- [keep_dims] if true, retains reduced dimensions with size 1.
Returns a new array with the log-sum-exp values.
*)vall1norm':arr->elt(**
[l1norm' arr] computes the L1 norm (sum of absolute values) of all elements in the array [arr].
Returns the L1 norm as an element.
*)vall2norm':arr->elt(**
[l2norm' arr] computes the L2 norm (Euclidean norm) of all elements in the array [arr].
Returns the L2 norm as an element.
*)vall2norm_sqr':arr->elt(**
[l2norm_sqr' arr] computes the squared L2 norm (sum of squared values) of all elements in the array [arr].
Returns the squared L2 norm as an element.
*)valclip_by_value:?amin:elt->?amax:elt->arr->arr(**
[clip_by_value ?amin ?amax arr] clips the values in the array [arr] to the range [amin, amax].
- [amin] specifies the minimum value to clip to.
- [amax] specifies the maximum value to clip to.
Returns a new array with the values clipped to the specified range.
*)valclip_by_l2norm:elt->arr->arr(**
[clip_by_l2norm max_norm arr] clips the values in the array [arr] so that the L2 norm does not exceed [max_norm].
Returns a new array with the values clipped by the specified L2 norm.
*)valpow:arr->arr->arr(**
[pow base exp] computes each element of the array [base] raised to the power of the corresponding element in [exp].
Returns a new array with the power values.
*)valscalar_pow:elt->arr->arr(**
[scalar_pow scalar arr] raises the scalar value [scalar] to the power of each element in the array [arr].
Returns a new array with the power values.
*)valpow_scalar:arr->elt->arr(**
[pow_scalar arr scalar] raises each element in the array [arr] to the power of the scalar value [scalar].
Returns a new array with the power values.
*)valatan2:arr->arr->arr(**
[atan2 y x] computes the element-wise arctangent of [y] / [x], using the signs of the elements to determine the correct quadrant.
Returns a new array with the arctangent values.
*)valscalar_atan2:elt->arr->arr(**
[scalar_atan2 scalar arr] computes the element-wise arctangent of [scalar] / each element in the array [arr].
Returns a new array with the arctangent values.
*)valatan2_scalar:arr->elt->arr(**
[atan2_scalar arr scalar] computes the element-wise arctangent of each element in the array [arr] / [scalar].
Returns a new array with the arctangent values.
*)valhypot:arr->arr->arr(**
[hypot x y] computes the hypotenuse (sqrt(x^2 + y^2)) for each element in the arrays [x] and [y].
Returns a new array with the hypotenuse values.
*)valmin2:arr->arr->arr(**
[min2 a b] computes the element-wise minimum of arrays [a] and [b].
Returns a new array with the minimum values.
*)valmax2:arr->arr->arr(**
[max2 a b] computes the element-wise maximum of arrays [a] and [b].
Returns a new array with the maximum values.
*)valadd:arr->arr->arr(**
[add a b] computes the element-wise addition of arrays [a] and [b].
Returns a new array with the sum of elements.
*)valsub:arr->arr->arr(**
[sub a b] computes the element-wise subtraction of arrays [a] and [b].
Returns a new array with the difference of elements.
*)valmul:arr->arr->arr(**
[mul a b] computes the element-wise multiplication of arrays [a] and [b].
Returns a new array with the product of elements.
*)valdiv:arr->arr->arr(**
[div a b] computes the element-wise division of arrays [a] and [b].
Returns a new array with the quotient of elements.
*)valadd_scalar:arr->elt->arr(**
[add_scalar arr scalar] adds the scalar value [scalar] to each element in the array [arr].
Returns a new array with the resulting values.
*)valsub_scalar:arr->elt->arr(**
[sub_scalar arr scalar] subtracts the scalar value [scalar] from each element in the array [arr].
Returns a new array with the resulting values.
*)valmul_scalar:arr->elt->arr(**
[mul_scalar arr scalar] multiplies each element in the array [arr] by the scalar value [scalar].
Returns a new array with the resulting values.
*)valdiv_scalar:arr->elt->arr(**
[div_scalar arr scalar] divides each element in the array [arr] by the scalar value [scalar].
Returns a new array with the resulting values.
*)valscalar_add:elt->arr->arr(**
[scalar_add scalar arr] adds the scalar value [scalar] to each element in the array [arr].
Returns a new array with the resulting values.
*)valscalar_sub:elt->arr->arr(**
[scalar_sub scalar arr] subtracts each element in the array [arr] from the scalar value [scalar].
Returns a new array with the resulting values.
*)valscalar_mul:elt->arr->arr(**
[scalar_mul scalar arr] multiplies each element in the array [arr] by the scalar value [scalar].
Returns a new array with the resulting values.
*)valscalar_div:elt->arr->arr(**
[scalar_div scalar arr] divides the scalar value [scalar] by each element in the array [arr].
Returns a new array with the resulting values.
*)valfma:arr->arr->arr->arr(**
[fma a b c] computes the fused multiply-add operation, multiplying arrays [a] and [b], then adding array [c].
Returns a new array with the resulting values.
*)valelt_equal:arr->arr->arr(**
[elt_equal a b] performs element-wise equality comparison between arrays [a] and [b].
Returns a new array where each element is [true] if the corresponding elements in [a] and [b] are equal, and [false] otherwise.
*)valelt_not_equal:arr->arr->arr(**
[elt_not_equal a b] performs element-wise inequality comparison between arrays [a] and [b].
Returns a new array where each element is [true] if the corresponding elements in [a] and [b] are not equal, and [false] otherwise.
*)valelt_less:arr->arr->arr(**
[elt_less a b] performs element-wise less-than comparison between arrays [a] and [b].
Returns a new array where each element is [true] if the corresponding element in [a] is less than that in [b], and [false] otherwise.
*)valelt_greater:arr->arr->arr(**
[elt_greater a b] performs element-wise greater-than comparison between arrays [a] and [b].
Returns a new array where each element is [true] if the corresponding element in [a] is greater than that in [b], and [false] otherwise.
*)valelt_less_equal:arr->arr->arr(**
[elt_less_equal a b] performs element-wise less-than-or-equal-to comparison between arrays [a] and [b].
Returns a new array where each element is [true] if the corresponding element in [a] is less than or equal to that in [b], and [false] otherwise.
*)valelt_greater_equal:arr->arr->arr(**
[elt_greater_equal a b] performs element-wise greater-than-or-equal-to comparison between arrays [a] and [b].
Returns a new array where each element is [true] if the corresponding element in [a] is greater than or equal to that in [b], and [false] otherwise.
*)valelt_equal_scalar:arr->elt->arr(**
[elt_equal_scalar arr scalar] performs element-wise equality comparison between each element in the array [arr] and the scalar value [scalar].
Returns a new array where each element is [true] if it equals [scalar], and [false] otherwise.
*)valelt_not_equal_scalar:arr->elt->arr(**
[elt_not_equal_scalar arr scalar] performs element-wise inequality comparison between each element in the array [arr] and the scalar value [scalar].
Returns a new array where each element is [true] if it does not equal [scalar], and [false] otherwise.
*)valelt_less_scalar:arr->elt->arr(**
[elt_less_scalar arr scalar] performs element-wise less-than comparison between each element in the array [arr] and the scalar value [scalar].
Returns a new array where each element is [true] if it is less than [scalar], and [false] otherwise.
*)valelt_greater_scalar:arr->elt->arr(**
[elt_greater_scalar arr scalar] performs element-wise greater-than comparison between each element in the array [arr] and the scalar value [scalar].
Returns a new array where each element is [true] if it is greater than [scalar], and [false] otherwise.
*)valelt_less_equal_scalar:arr->elt->arr(**
[elt_less_equal_scalar arr scalar] performs element-wise less-than-or-equal-to comparison between each element in the array [arr] and the scalar value [scalar].
Returns a new array where each element is [true] if it is less than or equal to [scalar], and [false] otherwise.
*)valelt_greater_equal_scalar:arr->elt->arr(**
[elt_greater_equal_scalar arr scalar] performs element-wise greater-than-or-equal-to comparison between each element in the array [arr] and the scalar value [scalar].
Returns a new array where each element is [true] if it is greater than or equal to [scalar], and [false] otherwise.
*)valconv1d:?padding:Owl_types.padding->arr->arr->intarray->arr(**
[conv1d ?padding input kernel strides] performs a 1-dimensional convolution on the [input] array using the specified [kernel].
- [padding] specifies the padding strategy (default is "valid").
- [strides] specifies the stride length.
Returns a new array with the result of the convolution.
*)valconv2d:?padding:Owl_types.padding->arr->arr->intarray->arr(**
[conv2d ?padding input kernel strides] performs a 2-dimensional convolution on the [input] array using the specified [kernel].
- [padding] specifies the padding strategy (default is "valid").
- [strides] specifies the stride length.
Returns a new array with the result of the convolution.
*)valconv3d:?padding:Owl_types.padding->arr->arr->intarray->arr(**
[conv3d ?padding input kernel strides] performs a 3-dimensional convolution on the [input] array using the specified [kernel].
- [padding] specifies the padding strategy (default is "valid").
- [strides] specifies the stride length.
Returns a new array with the result of the convolution.
*)valtranspose_conv1d:?padding:Owl_types.padding->arr->arr->intarray->arr(**
[transpose_conv1d ?padding input kernel strides] performs a 1-dimensional transposed convolution (also known as deconvolution) on the [input] array using the specified [kernel].
- [padding] specifies the padding strategy (default is "valid").
- [strides] specifies the stride length.
Returns a new array with the result of the transposed convolution.
*)valtranspose_conv2d:?padding:Owl_types.padding->arr->arr->intarray->arr(**
[transpose_conv2d ?padding input kernel strides] performs a 2-dimensional transposed convolution (also known as deconvolution) on the [input] array using the specified [kernel].
- [padding] specifies the padding strategy (default is "valid").
- [strides] specifies the stride length.
Returns a new array with the result of the transposed convolution.
*)valtranspose_conv3d:?padding:Owl_types.padding->arr->arr->intarray->arr(**
[transpose_conv3d ?padding input kernel strides] performs a 3-dimensional transposed convolution (also known as deconvolution) on the [input] array using the specified [kernel].
- [padding] specifies the padding strategy (default is "valid").
- [strides] specifies the stride length.
Returns a new array with the result of the transposed convolution.
*)valdilated_conv1d:?padding:Owl_types.padding->arr->arr->intarray->intarray->arr(**
[dilated_conv1d ?padding input kernel strides dilations] performs a 1-dimensional dilated convolution on the [input] array using the specified [kernel].
- [padding] specifies the padding strategy (default is "valid").
- [strides] specifies the stride length.
- [dilations] specifies the dilation rate.
Returns a new array with the result of the dilated convolution.
*)valdilated_conv2d:?padding:Owl_types.padding->arr->arr->intarray->intarray->arr(**
[dilated_conv2d ?padding input kernel strides dilations] performs a 2-dimensional dilated convolution on the [input] array using the specified [kernel].
- [padding] specifies the padding strategy (default is "valid").
- [strides] specifies the stride length.
- [dilations] specifies the dilation rate.
Returns a new array with the result of the dilated convolution.
*)valdilated_conv3d:?padding:Owl_types.padding->arr->arr->intarray->intarray->arr(**
[dilated_conv3d ?padding input kernel strides dilations] performs a 3-dimensional dilated convolution on the [input] array using the specified [kernel].
- [padding] specifies the padding strategy (default is "valid").
- [strides] specifies the stride length.
- [dilations] specifies the dilation rate.
Returns a new array with the result of the dilated convolution.
*)valmax_pool1d:?padding:Owl_types.padding->arr->intarray->intarray->arr(**
[max_pool1d ?padding input pool_size strides] applies a 1-dimensional max pooling operation on the [input] array.
- [padding] specifies the padding strategy (default is "valid").
- [pool_size] specifies the size of the pooling window.
- [strides] specifies the stride length.
Returns a new array with the result of the max pooling.
*)valmax_pool2d:?padding:Owl_types.padding->arr->intarray->intarray->arr(**
[max_pool2d ?padding input pool_size strides] applies a 2-dimensional max pooling operation on the [input] array.
- [padding] specifies the padding strategy (default is "valid").
- [pool_size] specifies the size of the pooling window.
- [strides] specifies the stride length.
Returns a new array with the result of the max pooling.
*)valmax_pool3d:?padding:Owl_types.padding->arr->intarray->intarray->arr(**
[max_pool3d ?padding input pool_size strides] applies a 3-dimensional max pooling operation on the [input] array.
- [padding] specifies the padding strategy (default is "valid").
- [pool_size] specifies the size of the pooling window.
- [strides] specifies the stride length.
Returns a new array with the result of the max pooling.
*)valavg_pool1d:?padding:Owl_types.padding->arr->intarray->intarray->arr(**
[avg_pool1d ?padding input pool_size strides] applies a 1-dimensional average pooling operation on the [input] array.
- [padding] specifies the padding strategy (default is "valid").
- [pool_size] specifies the size of the pooling window.
- [strides] specifies the stride length.
Returns a new array with the result of the average pooling.
*)valavg_pool2d:?padding:Owl_types.padding->arr->intarray->intarray->arr(**
[avg_pool2d ?padding input pool_size strides] applies a 2-dimensional average pooling operation on the [input] array.
- [padding] specifies the padding strategy (default is "valid").
- [pool_size] specifies the size of the pooling window.
- [strides] specifies the stride length.
Returns a new array with the result of the average pooling.
*)valavg_pool3d:?padding:Owl_types.padding->arr->intarray->intarray->arr(**
[avg_pool3d ?padding input pool_size strides] applies a 3-dimensional average pooling operation on the [input] array.
- [padding] specifies the padding strategy (default is "valid").
- [pool_size] specifies the size of the pooling window.
- [strides] specifies the stride length.
Returns a new array with the result of the average pooling.
*)valupsampling2d:arr->intarray->arr(**
[upsampling2d input size] performs a 2-dimensional upsampling on the [input] array.
- [size] specifies the upsampling factors for each dimension.
Returns a new array with the upsampled data.
*)valconv1d_backward_input:arr->arr->intarray->arr->arr(**
[conv1d_backward_input input kernel strides grad_output] computes the gradient of the loss with respect to the 1-dimensional [input] array.
- [input] is the original input array.
- [kernel] is the convolutional kernel used during the forward pass.
- [strides] specifies the stride length.
- [grad_output] is the gradient of the loss with respect to the output of the convolutional layer.
Returns a new array with the gradients of the input.
*)valconv1d_backward_kernel:arr->arr->intarray->arr->arr(**
[conv1d_backward_kernel input kernel strides grad_output] computes the gradient of the loss with respect to the 1-dimensional convolutional [kernel].
- [input] is the original input array.
- [kernel] is the convolutional kernel used during the forward pass.
- [strides] specifies the stride length.
- [grad_output] is the gradient of the loss with respect to the output of the convolutional layer.
Returns a new array with the gradients of the kernel.
*)valconv2d_backward_input:arr->arr->intarray->arr->arr(**
[conv2d_backward_input input kernel strides grad_output] computes the gradient of the loss with respect to the 2-dimensional [input] array.
- [input] is the original input array.
- [kernel] is the convolutional kernel used during the forward pass.
- [strides] specifies the stride length.
- [grad_output] is the gradient of the loss with respect to the output of the convolutional layer.
Returns a new array with the gradients of the input.
*)valconv2d_backward_kernel:arr->arr->intarray->arr->arr(**
[conv2d_backward_kernel input kernel strides grad_output] computes the gradient of the loss with respect to the 2-dimensional convolutional [kernel].
- [input] is the original input array.
- [kernel] is the convolutional kernel used during the forward pass.
- [strides] specifies the stride length.
- [grad_output] is the gradient of the loss with respect to the output of the convolutional layer.
Returns a new array with the gradients of the kernel.
*)valconv3d_backward_input:arr->arr->intarray->arr->arr(**
[conv3d_backward_input input kernel strides grad_output] computes the gradient of the loss with respect to the 3-dimensional [input] array.
- [input] is the original input array.
- [kernel] is the convolutional kernel used during the forward pass.
- [strides] specifies the stride length.
- [grad_output] is the gradient of the loss with respect to the output of the convolutional layer.
Returns a new array with the gradients of the input.
*)valconv3d_backward_kernel:arr->arr->intarray->arr->arr(**
[conv3d_backward_kernel input kernel strides grad_output] computes the gradient of the loss with respect to the 3-dimensional convolutional [kernel].
- [input] is the original input array.
- [kernel] is the convolutional kernel used during the forward pass.
- [strides] specifies the stride length.
- [grad_output] is the gradient of the loss with respect to the output of the convolutional layer.
Returns a new array with the gradients of the kernel.
*)valtranspose_conv1d_backward_input:arr->arr->intarray->arr->arr(**
[transpose_conv1d_backward_input input kernel strides grad_output] computes the gradient of the loss with respect to the 1-dimensional [input] array for the transposed convolution operation.
- [input] is the original input array.
- [kernel] is the transposed convolutional kernel used during the forward pass.
- [strides] specifies the stride length.
- [grad_output] is the gradient of the loss with respect to the output of the transposed convolutional layer.
Returns a new array with the gradients of the input.
*)valtranspose_conv1d_backward_kernel:arr->arr->intarray->arr->arr(**
[transpose_conv1d_backward_kernel input kernel strides grad_output] computes the gradient of the loss with respect to the 1-dimensional transposed convolutional [kernel].
- [input] is the original input array.
- [kernel] is the transposed convolutional kernel used during the forward pass.
- [strides] specifies the stride length.
- [grad_output] is the gradient of the loss with respect to the output of the transposed convolutional layer.
Returns a new array with the gradients of the kernel.
*)valtranspose_conv2d_backward_input:arr->arr->intarray->arr->arr(**
[transpose_conv2d_backward_input input kernel strides grad_output] computes the gradient of the loss with respect to the 2-dimensional [input] array for the transposed convolution operation.
- [input] is the original input array.
- [kernel] is the transposed convolutional kernel used during the forward pass.
- [strides] specifies the stride length.
- [grad_output] is the gradient of the loss with respect to the output of the transposed convolutional layer.
Returns a new array with the gradients of the input.
*)valtranspose_conv2d_backward_kernel:arr->arr->intarray->arr->arr(**
[transpose_conv2d_backward_kernel input kernel strides grad_output] computes the gradient of the loss with respect to the 2-dimensional transposed convolutional [kernel].
- [input] is the original input array.
- [kernel] is the transposed convolutional kernel used during the forward pass.
- [strides] specifies the stride length.
- [grad_output] is the gradient of the loss with respect to the output of the transposed convolutional layer.
Returns a new array with the gradients of the kernel.
*)valtranspose_conv3d_backward_input:arr->arr->intarray->arr->arr(**
[transpose_conv3d_backward_input input kernel strides grad_output] computes the gradient of the loss with respect to the 3-dimensional [input] array for the transposed convolution operation.
- [input] is the original input array.
- [kernel] is the transposed convolutional kernel used during the forward pass.
- [strides] specifies the stride length.
- [grad_output] is the gradient of the loss with respect to the output of the transposed convolutional layer.
Returns a new array with the gradients of the input.
*)valtranspose_conv3d_backward_kernel:arr->arr->intarray->arr->arr(**
[transpose_conv3d_backward_kernel input kernel strides grad_output] computes the gradient of the loss with respect to the 3-dimensional transposed convolutional [kernel].
- [input] is the original input array.
- [kernel] is the transposed convolutional kernel used during the forward pass.
- [strides] specifies the stride length.
- [grad_output] is the gradient of the loss with respect to the output of the transposed convolutional layer.
Returns a new array with the gradients of the kernel.
*)valdilated_conv1d_backward_input:arr->arr->intarray->intarray->arr->arr(**
[dilated_conv1d_backward_input input kernel strides dilations grad_output] computes the gradient of the loss with respect to the 1-dimensional [input] array for the dilated convolution operation.
- [input] is the original input array.
- [kernel] is the dilated convolutional kernel used during the forward pass.
- [strides] specifies the stride length.
- [dilations] specifies the dilation rate.
- [grad_output] is the gradient of the loss with respect to the output of the dilated convolutional layer.
Returns a new array with the gradients of the input.
*)valdilated_conv1d_backward_kernel:arr->arr->intarray->intarray->arr->arr(**
[dilated_conv1d_backward_kernel input kernel strides dilations grad_output] computes the gradient of the loss with respect to the 1-dimensional dilated convolutional [kernel].
- [input] is the original input array.
- [kernel] is the dilated convolutional kernel used during the forward pass.
- [strides] specifies the stride length.
- [dilations] specifies the dilation rate.
- [grad_output] is the gradient of the loss with respect to the output of the dilated convolutional layer.
Returns a new array with the gradients of the kernel.
*)valdilated_conv2d_backward_input:arr->arr->intarray->intarray->arr->arr(**
[dilated_conv2d_backward_input input kernel strides dilations grad_output] computes the gradient of the loss with respect to the 2-dimensional [input] array for the dilated convolution operation.
- [input] is the original input array.
- [kernel] is the dilated convolutional kernel used during the forward pass.
- [strides] specifies the stride length.
- [dilations] specifies the dilation rate.
- [grad_output] is the gradient of the loss with respect to the output of the dilated convolutional layer.
Returns a new array with the gradients of the input.
*)valdilated_conv2d_backward_kernel:arr->arr->intarray->intarray->arr->arr(**
[dilated_conv2d_backward_kernel input kernel strides dilations grad_output] computes the gradient of the loss with respect to the 2-dimensional dilated convolutional [kernel].
- [input] is the original input array.
- [kernel] is the dilated convolutional kernel used during the forward pass.
- [strides] specifies the stride length.
- [dilations] specifies the dilation rate.
- [grad_output] is the gradient of the loss with respect to the output of the dilated convolutional layer.
Returns a new array with the gradients of the kernel.
*)valdilated_conv3d_backward_input:arr->arr->intarray->intarray->arr->arr(**
[dilated_conv3d_backward_input input kernel strides dilations grad_output] computes the gradient of the loss with respect to the 3-dimensional [input] array for the dilated convolution operation.
- [input] is the original input array.
- [kernel] is the dilated convolutional kernel used during the forward pass.
- [strides] specifies the stride length.
- [dilations] specifies the dilation rate.
- [grad_output] is the gradient of the loss with respect to the output of the dilated convolutional layer.
Returns a new array with the gradients of the input.
*)valdilated_conv3d_backward_kernel:arr->arr->intarray->intarray->arr->arr(**
[dilated_conv3d_backward_kernel input kernel strides dilations grad_output] computes the gradient of the loss with respect to the 3-dimensional dilated convolutional [kernel].
- [input] is the original input array.
- [kernel] is the dilated convolutional kernel used during the forward pass.
- [strides] specifies the stride length.
- [dilations] specifies the dilation rate.
- [grad_output] is the gradient of the loss with respect to the output of the dilated convolutional layer.
Returns a new array with the gradients of the kernel.
*)valmax_pool1d_backward:padding->arr->intarray->intarray->arr->arr(**
[max_pool1d_backward padding input pool_size strides grad_output] computes the gradient of the loss with respect to the 1-dimensional [input] array after max pooling.
- [padding] specifies the padding strategy used during the forward pass.
- [input] is the original input array.
- [pool_size] specifies the size of the pooling window.
- [strides] specifies the stride length.
- [grad_output] is the gradient of the loss with respect to the output of the max pooling layer.
Returns a new array with the gradients of the input.
*)valmax_pool2d_backward:padding->arr->intarray->intarray->arr->arr(**
[max_pool2d_backward padding input pool_size strides grad_output] computes the gradient of the loss with respect to the 2-dimensional [input] array after max pooling.
- [padding] specifies the padding strategy used during the forward pass.
- [input] is the original input array.
- [pool_size] specifies the size of the pooling window.
- [strides] specifies the stride length.
- [grad_output] is the gradient of the loss with respect to the output of the max pooling layer.
Returns a new array with the gradients of the input.
*)valmax_pool3d_backward:padding->arr->intarray->intarray->arr->arr(**
[max_pool3d_backward padding input pool_size strides grad_output] computes the gradient of the loss with respect to the 3-dimensional [input] array after max pooling.
- [padding] specifies the padding strategy used during the forward pass.
- [input] is the original input array.
- [pool_size] specifies the size of the pooling window.
- [strides] specifies the stride length.
- [grad_output] is the gradient of the loss with respect to the output of the max pooling layer.
Returns a new array with the gradients of the input.
*)valavg_pool1d_backward:padding->arr->intarray->intarray->arr->arr(**
[avg_pool1d_backward padding input pool_size strides grad_output] computes the gradient of the loss with respect to the 1-dimensional [input] array after average pooling.
- [padding] specifies the padding strategy used during the forward pass.
- [input] is the original input array.
- [pool_size] specifies the size of the pooling window.
- [strides] specifies the stride length.
- [grad_output] is the gradient of the loss with respect to the output of the average pooling layer.
Returns a new array with the gradients of the input.
*)valavg_pool2d_backward:padding->arr->intarray->intarray->arr->arr(**
[avg_pool2d_backward padding input pool_size strides grad_output] computes the gradient of the loss with respect to the 2-dimensional [input] array after average pooling.
- [padding] specifies the padding strategy used during the forward pass.
- [input] is the original input array.
- [pool_size] specifies the size of the pooling window.
- [strides] specifies the stride length.
- [grad_output] is the gradient of the loss with respect to the output of the average pooling layer.
Returns a new array with the gradients of the input.
*)valavg_pool3d_backward:padding->arr->intarray->intarray->arr->arr(**
[avg_pool3d_backward padding input pool_size strides grad_output] computes the gradient of the loss with respect to the 3-dimensional [input] array after average pooling.
- [padding] specifies the padding strategy used during the forward pass.
- [input] is the original input array.
- [pool_size] specifies the size of the pooling window.
- [strides] specifies the stride length.
- [grad_output] is the gradient of the loss with respect to the output of the average pooling layer.
Returns a new array with the gradients of the input.
*)valupsampling2d_backward:arr->intarray->arr->arr(**
[upsampling2d_backward input size grad_output] computes the gradient of the loss with respect to the [input] array after 2-dimensional upsampling.
- [input] is the original input array.
- [size] specifies the upsampling factors for each dimension.
- [grad_output] is the gradient of the loss with respect to the output of the upsampling layer.
Returns a new array with the gradients of the input.
*)valrow_num:arr->int(**
[row_num arr] returns the number of rows in the array [arr].
*)valcol_num:arr->int(**
[col_num arr] returns the number of columns in the array [arr].
*)valrow:arr->'a->arr(**
[row arr idx] extracts the row at index [idx] from the array [arr].
Returns a new array containing the specified row.
*)valrows:arr->intarray->arr(**
[rows arr indices] extracts multiple rows specified by [indices] from the array [arr].
Returns a new array containing the selected rows.
*)valcopy_row_to:arr->'a->'b->unit(**
[copy_row_to src src_idx dest_idx] copies the row at index [src_idx] in the array [src] to the row at index [dest_idx].
*)valcopy_col_to:arr->'a->'b->unit(**
[copy_col_to src src_idx dest_idx] copies the column at index [src_idx] in the array [src] to the column at index [dest_idx].
*)valdiag:?k:int->arr->arr(**
[diag ?k arr] extracts the k-th diagonal from the array [arr]. If [k] is not provided, the main diagonal is extracted.
Returns a new array containing the diagonal elements.
*)valtrace:arr->elt(**
[trace arr] computes the sum of the elements on the main diagonal of the array [arr].
Returns the trace as an element.
*)valdot:arr->arr->arr(**
[dot a b] computes the dot product of the arrays [a] and [b].
Returns a new array with the result of the dot product.
*)valtranspose:?axis:intarray->arr->arr(**
[transpose ?axis arr] transposes the array [arr]. If [axis] is provided, the transpose is performed according to the specified axes.
Returns a new array with the transposed data.
*)valto_rows:arr->'aarray(**
[to_rows arr] converts the array [arr] into an array of row vectors.
Returns an array where each element is a row from the original array.
*)valof_rows:arrarray->arr(**
[of_rows rows] creates an array by stacking the row vectors in [rows].
Returns a new array constructed from the row vectors.
*)valto_cols:arr->'aarray(**
[to_cols arr] converts the array [arr] into an array of column vectors.
Returns an array where each element is a column from the original array.
*)valof_cols:arrarray->arr(**
[of_cols cols] creates an array by stacking the column vectors in [cols].
Returns a new array constructed from the column vectors.
*)valof_array:eltarray->intarray->arr(**
[of_array data shape] creates an array from a flat array [data] with the specified [shape].
Returns a new array with the data arranged according to the shape.
*)valof_arrays:eltarrayarray->arr(**
[of_arrays data] creates an array from a 2D array [data], where each sub-array represents a row.
Returns a new array with the data from the 2D array.
*)valto_arrays:arr->eltarrayarray(**
[to_arrays arr] converts the array [arr] into a 2D array where each sub-array represents a row.
Returns a 2D array with the data from the original array.
*)(** {5 Scalar functions} *)moduleScalar:sigvaladd:elt->elt->elt(**
[add a b] returns the sum of the scalars [a] and [b].
*)valsub:elt->elt->elt(**
[sub a b] returns the difference of the scalars [a] and [b].
*)valmul:elt->elt->elt(**
[mul a b] returns the product of the scalars [a] and [b].
*)valdiv:elt->elt->elt(**
[div a b] returns the quotient of the scalars [a] and [b].
*)valpow:elt->elt->elt(**
[pow a b] returns the scalar [a] raised to the power of [b].
*)valatan2:elt->elt->elt(**
[atan2 y x] returns the arctangent of [y / x], considering the signs of [x] and [y] to determine the correct quadrant.
*)valabs:elt->elt(**
[abs a] returns the absolute value of the scalar [a].
*)valneg:elt->elt(**
[neg a] returns the negation of the scalar [a].
*)valsqr:elt->elt(**
[sqr a] returns the square of the scalar [a].
*)valsqrt:elt->elt(**
[sqrt a] returns the square root of the scalar [a].
*)valexp:elt->elt(**
[exp a] returns the exponential of the scalar [a].
*)vallog:elt->elt(**
[log a] returns the natural logarithm of the scalar [a].
*)vallog2:elt->elt(**
[log2 a] returns the base-2 logarithm of the scalar [a].
*)vallog10:elt->elt(**
[log10 a] returns the base-10 logarithm of the scalar [a].
*)valsignum:elt->elt(**
[signum a] returns the signum function of the scalar [a], which is -1 for negative, 0 for zero, and 1 for positive values.
*)valfloor:elt->elt(**
[floor a] returns the greatest integer less than or equal to the scalar [a].
*)valceil:elt->elt(**
[ceil a] returns the smallest integer greater than or equal to the scalar [a].
*)valround:elt->elt(**
[round a] returns the nearest integer to the scalar [a].
*)valsin:elt->elt(**
[sin a] returns the sine of the scalar [a].
*)valcos:elt->elt(**
[cos a] returns the cosine of the scalar [a].
*)valtan:elt->elt(**
[tan a] returns the tangent of the scalar [a].
*)valsinh:elt->elt(**
[sinh a] returns the hyperbolic sine of the scalar [a].
*)valcosh:elt->elt(**
[cosh a] returns the hyperbolic cosine of the scalar [a].
*)valtanh:elt->elt(**
[tanh a] returns the hyperbolic tangent of the scalar [a].
*)valasin:elt->elt(**
[asin a] returns the arcsine of the scalar [a].
*)valacos:elt->elt(**
[acos a] returns the arccosine of the scalar [a].
*)valatan:elt->elt(**
[atan a] returns the arctangent of the scalar [a].
*)valasinh:elt->elt(**
[asinh a] returns the inverse hyperbolic sine of the scalar [a].
*)valacosh:elt->elt(**
[acosh a] returns the inverse hyperbolic cosine of the scalar [a].
*)valatanh:elt->elt(**
[atanh a] returns the inverse hyperbolic tangent of the scalar [a].
*)valrelu:elt->elt(**
[relu a] applies the Rectified Linear Unit (ReLU) function to the scalar [a], returning [max(0, a)].
*)valdawsn:elt->elt(**
[dawsn a] returns Dawson's function of the scalar [a].
*)valsigmoid:elt->elt(**
[sigmoid a] returns the sigmoid function of the scalar [a].
*)endmoduleMat:sigvaleye:int->arr(**
[eye n] creates an [n] x [n] identity matrix, where all the elements on the main diagonal are 1, and all other elements are 0.
Returns a new array representing the identity matrix.
*)valdiagm:?k:int->arr->arr(**
[diagm ?k v] creates a diagonal matrix from the array [v].
- [k] specifies the diagonal to fill. The main diagonal is 0, positive values refer to diagonals above the main, and negative values refer to diagonals below the main.
Returns a new array representing the diagonal matrix.
*)valtriu:?k:int->arr->arr(**
[triu ?k a] returns the upper triangular part of the array [a], with elements below the k-th diagonal zeroed.
The main diagonal is 0, positive values refer to diagonals above the main, and negative values refer to diagonals below the main.
Returns a new array with the upper triangular part.
*)valtril:?k:int->arr->arr(**
[tril ?k a] returns the lower triangular part of the array [a], with elements above the k-th diagonal zeroed.
The main diagonal is 0, positive values refer to diagonals above the main, and negative values refer to diagonals below the main.
Returns a new array with the lower triangular part.
*)endmoduleLinalg:sigvalinv:arr->arr(**
[inv a] computes the inverse of the matrix [a].
Returns a new array representing the inverse matrix.
*)vallogdet:arr->elt(**
[logdet a] computes the natural logarithm of the determinant of the matrix [a].
Returns the logarithm of the determinant as a scalar.
*)valchol:?upper:bool->arr->arr(**
[chol ?upper a] performs the Cholesky decomposition of the positive-definite matrix [a].
- [upper] specifies whether to return the upper or lower triangular matrix. If [upper] is true, returns the upper triangular matrix, otherwise the lower triangular matrix.
Returns a new array representing the Cholesky factor.
*)valqr:arr->arr*arr(**
[qr a] performs the QR decomposition of the matrix [a].
Returns a tuple of two arrays (Q, R), where [Q] is an orthogonal matrix and [R] is an upper triangular matrix.
*)vallq:arr->arr*arr(**
[lq a] performs the LQ decomposition of the matrix [a].
Returns a tuple of two arrays (L, Q), where [L] is a lower triangular matrix and [Q] is an orthogonal matrix.
*)valsvd:?thin:bool->arr->arr*arr*arr(**
[svd ?thin a] performs the Singular Value Decomposition (SVD) of the matrix [a].
- [thin] specifies whether to return the reduced form of the SVD.
Returns a tuple of three arrays (U, S, V), where [U] and [V] are orthogonal matrices, and [S] is a diagonal matrix containing the singular values.
*)valsylvester:arr->arr->arr->arr(**
[sylvester a b c] solves the Sylvester equation A*X + X*B = C for the unknown matrix X.
Returns a new array representing the solution matrix X.
*)vallyapunov:arr->arr->arr(**
[lyapunov a q] solves the continuous Lyapunov equation A*X + X*A^T = Q for the unknown matrix X.
Returns a new array representing the solution matrix X.
*)valdiscrete_lyapunov:?solver:[`default|`bilinear|`direct]->arr->arr->arr(**
[discrete_lyapunov ?solver a q] solves the discrete Lyapunov equation A*X*A^T - X + Q = 0 for the unknown matrix X.
- [solver] specifies the method to use: `default`, `bilinear`, or `direct`.
Returns a new array representing the solution matrix X.
*)vallinsolve:?trans:bool->?typ:[`n|`u|`l]->arr->arr->arr(**
[linsolve ?trans ?typ a b] solves the linear system A*X = B for the unknown matrix X.
- [trans] specifies whether to transpose the matrix A.
- [typ] specifies the type of matrix A: `n` for normal, `u` for upper triangular, and `l` for lower triangular.
Returns a new array representing the solution matrix X.
*)valcare:?diag_r:bool->arr->arr->arr->arr->arr(**
[care ?diag_r a b q r] solves the Continuous-time Algebraic Riccati Equation (CARE) A*X + X*A^T - X*B*R^-1*B^T*X + Q = 0 for the unknown matrix X.
- [diag_r] if true, [R] is assumed to be diagonal.
Returns a new array representing the solution matrix X.
*)valdare:?diag_r:bool->arr->arr->arr->arr->arr(**
[dare ?diag_r a b q r] solves the Discrete-time Algebraic Riccati Equation (DARE) A*X*A^T - X - (A*X*B^T)*inv(B*X*B^T + R)*(A*X*B^T)^T + Q = 0 for the unknown matrix X.
- [diag_r] if true, [R] is assumed to be diagonal.
Returns a new array representing the solution matrix X.
*)endend