44 lines
1.2 KiB
OCaml
44 lines
1.2 KiB
OCaml
(** Power function implementations for bitarrays *)
|
|
|
|
open Scalable
|
|
open Scalable_basic_arithmetics
|
|
|
|
(* Naive and fast exponentiation ; already implemented in-class in the
|
|
built-in integer case.
|
|
*)
|
|
|
|
(** Naive power function. Linear complexity
|
|
@param x base, a bitarray
|
|
@param n exponent, a non-negative bitarray
|
|
*)
|
|
let pow x n = []
|
|
|
|
(** Fast bitarray exponentiation function. Logarithmic complexity.
|
|
@param x base, a bitarray
|
|
@param n exponent, a non-negative bitarray
|
|
*)
|
|
let power x n = []
|
|
|
|
(* Modular expnonentiation ; modulo a given natural (bitarray without
|
|
sign bits).
|
|
*)
|
|
|
|
(** Fast modular exponentiation function. Logarithmic complexity.
|
|
@param x base, a bitarray
|
|
@param n exponent, a non-negative bitarray
|
|
@param m modular base, a positive bitarray
|
|
*)
|
|
let mod_power x n m = []
|
|
|
|
(* Making use of Fermat Little Theorem for very quick exponentation
|
|
modulo prime number.
|
|
*)
|
|
|
|
(** Fast modular exponentiation function mod prime. Logarithmic complexity.
|
|
It makes use of the Little Fermat Theorem.
|
|
@param x base, a bitarray
|
|
@param n exponent, a non-negative bitarray
|
|
@param p prime modular base, a positive bitarray
|
|
*)
|
|
let prime_mod_power x n p = []
|