Packages
mmath
0.2.0-alpha8
0.2.26
0.2.25
0.2.24
0.2.23
0.2.22
0.2.21
0.2.20
0.2.19
0.2.18
0.2.17
0.2.16
0.2.15
0.2.14
0.2.13
0.2.12
0.2.11
0.2.10
0.2.9
0.2.8
0.2.7
0.2.6
0.2.5
0.2.4
0.2.3
0.2.2
0.2.1
0.2.0
0.2.0-alpha9
0.2.0-alpha8
0.2.0-alpha7
0.2.0-alpha6
0.2.0-alpha5
0.2.0-alpha4
0.2.0-alpha3
0.2.0-alpha2
0.2.0-alpha10
0.2.0-alpha1
0.2.0-alpha
0.1.17-alpha
0.1.16
0.1.15
0.1.14
0.1.13
0.1.11
0.1.10
0.1.9
0.1.8
0.1.7
0.1.6
math library for metric sequences and binary arrays.
Current section
Files
Jump to
Current section
Files
src/mmath_trans.erl
%%%-------------------------------------------------------------------
%%% @author Heinz Nikolaus Gies <heinz@licenser.net>
%%% @copyright (C) 2014, Heinz Nikolaus Gies
%%% @doc
%%% Functions that transform metric.
%%% @end
%%% Created : 8 Jun 2014 by Heinz Nikolaus Gies <heinz@licenser.net>
%%%-------------------------------------------------------------------
-module(mmath_trans).
-export([
derivate/1,
confidence/1,
mul/2,
divide/2]).
-include("mmath.hrl").
-define(APPNAME, mmath).
-define(LIBNAME, trans_nif).
-on_load(load_nif/0).
load_nif() ->
SoName = case code:priv_dir(?APPNAME) of
{error, bad_name} ->
case filelib:is_dir(filename:join(["..", priv])) of
true ->
filename:join(["..", priv, ?LIBNAME]);
_ ->
filename:join([priv, ?LIBNAME])
end;
Dir ->
filename:join(Dir, ?LIBNAME)
end,
erlang:load_nif(SoName, 0).
%%--------------------------------------------------------------------
%% @doc
%% Multiplies each value in the binary with the provided integer.
%% @end
%%--------------------------------------------------------------------
-spec mul(binary(), pos_integer()) -> binary().
mul(_M, _D) ->
erlang:nif_error(nif_library_not_loaded).
%%--------------------------------------------------------------------
%% @doc
%% Divides each value in the binary with the provided integer.
%% @end
%%--------------------------------------------------------------------
-spec divide(binary(), pos_integer()) -> binary().
divide(_M, _D) ->
erlang:nif_error(nif_library_not_loaded).
%%--------------------------------------------------------------------
%% @doc
%% Calculates the derivate of the values, this means the first value
%% is dropped (or taken as the initial value) with each following
%% value being calculated by derivate(n) = value(n) - value(n-1).
%%
%% The resulting binary will be one ellement shorter!
%% @end
%%--------------------------------------------------------------------
-spec derivate(binary()) -> binary().
derivate(_) ->
erlang:nif_error(nif_library_not_loaded).
%%--------------------------------------------------------------------
%% @doc
%% Transforms the series into the confidence score for each value.
%% Unset values have a confidence of 0% while set values have a
%% confidence of 100%. Aggregated values have the aggreated confidence
%% score.
%% @end
%%--------------------------------------------------------------------
-spec confidence(binary()) -> binary().
confidence(_) ->
erlang:nif_error(nif_library_not_loaded).