package osdp

  1. Overview
  2. Docs

Module LinExpr.QSource

Sourcemodule Coeff = Scalar.Q

Type of coefficients.

Sourcetype t

Type of affine expressions.

Conversion functions.

Sourceval of_list : (Ident.t * Coeff.t) list -> Coeff.t -> t

of_list [(x_1, a_1);..; (x_n, a_n)] c builds the affine expression a_1 x_1 + ... + a_n x_n + c. Duplicates or zeros coefficients are accepted (for instance 2 x_0 + 0 x_1 + 3 x_0 is a valid input for 5 x_0).

Sourceval to_list : t -> (Ident.t * Coeff.t) list * Coeff.t

Returns a list sorted in increasing order of Ident.compare without duplicates nor zeros.

A few values.

Sourceval var : Ident.t -> t

Same as of_list with the list [ident, Coeff.one] and constant Coeff.zero.

Sourceval const : Coeff.t -> t

Same as of_list with an empty list.

Arithmetic operations.

Sourceval mult_scalar : Coeff.t -> t -> t
Sourceval add : t -> t -> t
Sourceval sub : t -> t -> t
Sourceval replace : t -> (Ident.t * t) list -> t

compose le [v_1, l_1;...; v_n, l_n] replaces each variable v_i by l_i in l. No duplicates are allowed.

Sourceval remove : t -> Ident.t -> t

Various operations.

Sourceval compare : t -> t -> int
Sourceval is_var : t -> (Ident.t * Coeff.t) option
Sourceval is_const : t -> Coeff.t option
Sourceval choose : t -> (Ident.t * Coeff.t) option

Returns one of the (non zero) coefficients in the linear expression (if any).

Printing.

Sourceval pp : Format.formatter -> t -> unit
OCaml

Innovation. Community. Security.