MatrixBerryCore
Namespaces | Classes | Functions
mxberry::core Namespace Reference

Namespaces

 cell
 
 check
 
 cont
 
 obj
 
 sort
 
 string
 
 struct
 
 test
 
 type
 

Classes

class  MExceptionUtils
 

Functions

function absrelcompare (in leftArr, in rightArr, in absTol, in relTol, in fNormOp)
 ABSRELCOMPARE - compares two numerical arrays by user defined norm. For each two corresponding fNormOp input elements from the leftArr (argL) and the rightArr (argR) the function calculates: More...
 
function cat (in dimNum, in varargin)
 
function cellfunallelem (in hFunc, in inpCell, in varargin)
 CELLFUNALLELEM applies the specified function to all elements in each cell of the specified cell array and returns array of results for each cell. More...
 
function checkmultvar (in typeSpec, in nPlaceHolders, in varargin)
 CHECKMULTVAR checks a generic condition provided by typeSpec string in the following format: 'isnumeric(x1)&&isa(x2,'int32')||isscalar(x2)' etc In case validation fails an exception is thrown. More...
 
function assignIn (in varName, in varValue)
 
function checksize (in varargin)
 CHECKSIZE checks sizes of arrays;. More...
 
function checkvar (in x, in typeSpec, in varargin)
 CHECKVAR checks a generic condition provided by typeSpec string in the following format: 'isnumeric(x)&&isa(x,'int32')||isscalar(x)' etc In case validation fails an exception is thrown. More...
 
function combvec (in varargin)
 COMBVEC creates a matrix of combinations with elements from input vectors. More...
 
function addBlockedInd (in indMat, in nElems)
 
function addInterleavedInd (in indMat, in nElems)
 
function createarray (in varargin)
 
function genfilename (in inpStr)
 GENFILENAME generates a valid file name based on a given string. More...
 
function genteststruct (in inpNum)
 GENTESTSTRUCT generates a complex test structure using input number to guarantee a uniqueness. More...
 
function filesep ()
 
function getcallername (in nStepsUp, in mode)
 GETCALLERNAME returns a name of caller determined by a number of steps up in the call stacks. More...
 
function getcallernameext (in indStack)
 GETCALLERNAME determines function/script name or method name of caller together with class name in the case it is method of class for element of stack given by its index (this index is 1 for immediate caller of this function) More...
 
function getfirstdimsize (in value, in nDims)
 GETFIRSTDIMSIZE returns a size vector for the first N dimensions where N is specified. More...
 
function hash (in inpArr, in methodName)
 OBJECTHASH counts the hash of input object/array. More...
 
function structhash (in structB, in methodName)
 
function cellhash (in cellB, in methodName)
 
function hashinner (in inpArr, in meth)
 HASH - Convert an input variable into a message digest using any of several common hash algorithms. More...
 
function ind2submat (in sizeVec, in indVec)
 IND2SUBMAT works similarly to the built-in ind2sub function but returns all the indices in a single matrix. More...
 
function iscelllogical (in value)
 
function iscellnumeric (in valueArr)
 ISCELLNUMERIC returns true for a cell arrays consisting of numeric elements only. More...
 
function iscol (in inpArray)
 
function isequalcellelemsize (in value1, in value2)
 
function isequalfirstdimsize (in firstArr, in secArr, in nDims)
 ISEQUALFIRSTDIMSIZE checks if the specified arrays have the same size along the first N dimensions where N is specified. More...
 
function isfirstdimsizeasspecified (in valueArr, in sizeVec)
 ISFIRSTDIMSIZEASSPECIFIED check if an input value have a specified size along the first dimensions. More...
 
function ismember (in leftVec, in rightVec, in varargin)
 ISMEMBER - ismember implementation for arrays of any type. More...
 
function ismemberbyfunc (in leftVec, in rightVec, in fCompare)
 ISMEMBERBYFUNC - ismember implementation for arrays of any type where an element comparison is performed by a specified function. This function is useful when elements are not sortable i.e. EITHER an implementation of ,,,,, does not define a full order OR there is no an implementation of method that calls these operators. More...
 
function ismembercellstr (in leftList, in rightList, in isHigherIndexUsed)
 ISMEMBERCELLSTR produces the same results as the built-in function "ismember" looking for the higher index if isHigherIndexUsed =true and lower index if isHigherIndexUsed=false (default) More...
 
function ismemberjoint (in leftCArr, in rightCArr, in varargin)
 ISMEMBERJOINT perform joint ismember operation for two cell arrays. More...
 
function ismemberjointwithnulls (in leftCVec, in leftIsNullCVec, in rightCVec, in rightIsNullCVec, in dim)
 ISMEMBERJOINTWITHNULLS perform joint ismember operation for two cell arrays for which also cell arrays detemining positions of null values are given. More...
 
function checkValueAndIsNullConsistency (in nameStr, in valueCVec, in isNullCVec, in nDimsCVec, in isnValueVec)
 
function ismemberrows (in inpLeftMat, in inpRightMat, in isInteger, in forceMode)
 ISMEMBERROWS finds indices of rows from the first matrix in the second matrix, i.e. it is the more efficient version of ISMEMBER(. . .,'rows') More...
 
function ismembersortableobj (in firstVec, in secVec)
 ISMEMBER implementation strictly for sortable entities i.e. for those that have 1) full order defined by implementation of comparison operators /isequal/isequaln/isequaln, , , , , 2) an implementation of method that uses these operators. More...
 
function isrow (in inpArray)
 
function isunique (in inpVec)
 
function isvalidsize (in varargin)
 ISVALIDSIZE compares size of input arrays with size mask. Size mask can contain nans that allow any size for a corresponding dimension. Function automatically adds 1 at the end of size. For example, array 3x2 is also array 3x2x1 and 3x2x1x1x1 e.t.c;. More...
 
function isvar (in varName)
 
function isvec (in inpArray)
 
function num2cell (in inpArray, in varargin)
 NUM2CELL is an extension of Matlab built-in function "num2cell" designed to work correctly with empty arrays (such as zero(10,0)) for instance. More...
 
function parseparams (in args, in propNameList, in nRegExpected, in nPropExpected)
 PARSEPARAMS behaves exactly as a built-in Matlab function apart from the incorrect behavior of Matlab function in cases when the regular argument has a character type. Additionally the function allows to avoid a misinterpretation of symbolical values of regular parameters via listing all the allowed properties. More...
 
function parseparext (in args, in propNameValMat, in varargin)
 PARSEPAREXT behaves in the same way as mxberry.core.parseparams but returns property values in a more convenient form. More...
 
function parsestackelem (in SStackElem)
 PARSESTACKELEM parses structure for given element of stack and returns the corresponding function/script name or method name together with class name in the case the element corresponds to some method of class. More...
 
function repmat (in inpArray, in varargin)
 
function roundn (in inpArr, in indexExp)
 ROUNDN rounds to multiple of 10^indexExp. More...
 
function subreffrontdim (in inpArray, in curInd)
 
function throwerror (in msgTag, in varargin)
 THROWERROR works similarly to built-in ERROR function in case when there is no output arguments but simpler to use as it automatically generates tags based on caller name When output argument is specified an exception object is returned instead. More...
 
function throwwarn (in msgTag, in varargin)
 THROWWARN works similarly to built-in WARNING function in case when there is no output arguments but simpler to use as it automatically generates tags based on caller name When output argument is specified an exception object is returned instead. More...
 
function unionjoint (in leftCell, in rightCell)
 UNIONJOINT calculates union of corresponding elements of two cell arrays jointly accross all cell array elements. More...
 
function smartcat (in xArray, in yArray)
 
function unique (in inpVec)
 UNIQUE for arrays of any type. More...
 
function uniquebyfunc (in inpVec, in fCompare, in algoName)
 UNIQUEBYFUNC unique for arrays of any type where an element comparison is performed by a specified function. More...
 
function uniquejoint (in inpCArr, in varargin)
 UNIQUEJOINT perform joint unique operation for cell arrays. More...
 
function uniquerows (in inpMat, in isInteger, in forceMode)
 UNIQUEROWS finds unique rows in input matrix, i.e. the more effective version of UNIQUE(. . .,'rows') More...
 
function uniquesortableobj (in inpVec)
 UNIQUE implementation strictly for sortable entities i.e. for those that have 1) full order defined by implementation of comparison operators /isequal/isequaln/isequaln, , , , , 2) an implementation of method that uses these operators. More...
 

Function Documentation

◆ absrelcompare()

function mxberry::core::absrelcompare ( in  leftArr,
in  rightArr,
in  absTol,
in  relTol,
in  fNormOp 
)

ABSRELCOMPARE - compares two numerical arrays by user defined norm. For each two corresponding fNormOp input elements from the leftArr (argL) and the rightArr (argR) the function calculates:

*    1) Absolute difference if:
*         fNormOp(argL - argR) <= absTol
*    or
*         fNormOp(argL) + fNormOp(argR) <= absTol.
* 
*    The absolute difference is calculated as:
*         fNormOp(argL - argR)
* 
*    2) Absolute and relative difference in other cases. The relative
*    difference is calculated as:
* 
*         2 * fNormOp(argL - argR) / (fNormOp(argL) + fNormOp(argR))
* 
*    The maximum absolute difference for all elements is returned as
*    absDiff. If the relative difference has been calculated for some
*    elements, then the relative difference value for maximum element
*    returns as relDiff, the maximum absolute difference for this element as
*    absMRelDiff.
* 
* 
*  Input:
*      regular:
* 
*          leftArr, rightArr: double[nElemsDim1,. . ., nElemsDimk] - input
*                             arrays with the same size.
* 
*          absTol: double[1, 1] - the absolute difference calculation
*                  threshold for the algorithm. If relTol is empty, the
*                  absTol is the maximum allowed absolute tolerance.
* 
*          relTol: double[1, 1] - the maximum allowed relative tolerance. If
*                  it is empty, then relative precision isn't calculated.
* 
*          fNormOp: function_handle[1, 1] - norm(x) operator handle. The
*                   function must have the format:
* 
*                   normArr = fNormOp(inpArr)
* 
*                        Input:
*                            inpArr: double[nElemsDim1,. . ., nElemsDimk] - an
*                                    input array.
* 
*                        Output:
*                            normArr: double[..] - an output array with norm
*                                     for each element. The type of
*                                     element is specified by user (it can
*                                     be the vector, for example), so the
*                                     numerical array normArr can have any
*                                     size. The only condition is:
* 
*                                        size(fNormOp(inp1Arr)) == . . .
*                                            size(fNormOp(inp2Arr)),
* 
*                                     for all inp1Arr and inp2Arr with the
*                                     same size.
* 
*  Output:
* 
*          isEqual: logical[1, 1] - are two input arrays equal with defined
*                   tolerances.
* 
*          absDiff: double[1, 1] - the maximum absolute difference (from all
*                   elements).
* 
*          isRelDiffTriggered: logical[1, 1] - has the relative comparison
*                              been used.
* 
*          relDiff: double[1, 1] - the maximum relative difference (from all
*                   elements for which it was calculated). If the relative
*                   comparison hasn't been used, it is empty.
* 
*          absMRelDiff: double[1, 1] - the absolute difference for the
*                       element with maximum relative difference value. If
*                       there are more elemets than one with the same
*                       relative difference value, then the maximum absolute
*                       difference value among them is returned. If the
*                       relative comparison hasn't been used, it is empty.
* 
*          reportStr: char[1,..] standart error report or empty string if no
*                     error has occured.
* 
*  Example:
*      If you want to compare only absolute difference with absTol, you can
*      use:
* 
*          [isEqual, absDiff] = absrelcompare(aArr, bArr, absTol, [], @abs)
* 
*      If you want to compare only relative difference with relTol, you can
*      use:
* 
*          [isEqual, ~, ~, relDiff] = . . .
*                absrelcompare(aArr, bArr, Inf, relTol, @abs)
* 
*      You also can compare relative difference between two vectors norm:
* 
*          [isEqual, ~, ~, relDiff] = . . .
*                absrelcompare(aVec, bVec, Inf, relTol, @norm)
* 
Author
Peter Gagarinov, PhD pgaga.nosp@m.rino.nosp@m.v@gma.nosp@m.il.c.nosp@m.om,
Yuri Admiralsky swige.nosp@m..ide.nosp@m.@gmai.nosp@m.l.co.nosp@m.m

◆ addBlockedInd()

function mxberry::core::addBlockedInd ( in  indMat,
in  nElems 
)

◆ addInterleavedInd()

function mxberry::core::addInterleavedInd ( in  indMat,
in  nElems 
)

◆ assignIn()

function mxberry::core::assignIn ( in  varName,
in  varValue 
)

◆ cat()

function mxberry::core::cat ( in  dimNum,
in  varargin 
)
Author
Peter Gagarinov, PhD pgaga.nosp@m.rino.nosp@m.v@gma.nosp@m.il.c.nosp@m.om

◆ cellfunallelem()

function mxberry::core::cellfunallelem ( in  hFunc,
in  inpCell,
in  varargin 
)

CELLFUNALLELEM applies the specified function to all elements in each cell of the specified cell array and returns array of results for each cell.

*  Input:
*    regular:
*        hFunc: function_handle[1,1] - function to apply to all elements
*        inpCell: cell[nElem1,. . .,nElemN] - input array
* 
*    properties:
*        same properties as a built-in cellfun function
*           (UniformOutput for instance is supported)
* 
*  Output:
*    resArray: numeric/logical[nElem1,. . .,nElemN] - calcualtion result
* 
* 
*  Example:
*    mxberry.core.cellfunallelem(@any,{true,[false true;true true]})
*    ans =
*         1     1
* 
Author
Peter Gagarinov, PhD pgaga.nosp@m.rino.nosp@m.v@gma.nosp@m.il.c.nosp@m.om

◆ cellhash()

function mxberry::core::cellhash ( in  cellB,
in  methodName 
)

◆ checkmultvar()

function mxberry::core::checkmultvar ( in  typeSpec,
in  nPlaceHolders,
in  varargin 
)

CHECKMULTVAR checks a generic condition provided by typeSpec string in the following format: 'isnumeric(x1)&&isa(x2,'int32')||isscalar(x2)' etc In case validation fails an exception is thrown.

*  Input:
*    regular:
*        typeSpec: char[1,]/function_handle - check string in
*            the folowing format: 'isnumeric(x)&&ischar(x)'
*                        OR
*            function_handle[1,1]
*        nPlaceHolders: numberic[1,1] - number of place holders/arguments in
*            typeSpec
* 
*        x1: anyType[]
*        x2: anyType[]
*        x3: anyType[]
* 
*    properties:
*        varNameList: cell[1,nVars] of char[1,] - list of variable names
*            used in the automatically generated error message.
*            Moreover the condition nVars<=nPlaceHolders must hold.
*        errorTag: char[1,] - tag for MException object thrown
*            in case of error. If not specified
*            '<CALLER_NAME>:wrongInput' tag is used
*        errorMessage: char[1,] - error message for MException object
*            thrown in case of error. If not specified the message
*            is generated automatically.
*        nCallerStackStepsUp: numeric[1,1] - number of steps up in the call
*            stacks for the caller, by which name the full message tag is to
*            be generated, =1 by default
*  Example:
* 
*    mxberry.core.checkmultvar('numel(x1)==numel(x2)',2,a,b,. . .
*        'varNameList',{'Alpha'},'errorTag','wrongInput:badType',. . .
*        'errorMessage','Inputs are wrong')
* 
Author
Peter Gagarinov, PhD pgaga.nosp@m.rino.nosp@m.v@gma.nosp@m.il.c.nosp@m.om

◆ checksize()

function mxberry::core::checksize ( in  varargin)

CHECKSIZE checks sizes of arrays;.

*  Usage isValid=checksize(arr1,arr2,arr3,siz);
* 
*  Input:
*    regular:
*        firstArr: any[]
*        . . .. . .
*        lastArr: any[]
*        sizeVec: double[1,nDims] - mask for check of size;
* 
*  Output:
*    isValid: logical[1,1] - true if all arrays is proper with
*        mask
* 
Author
Peter Gagarinov, PhD pgaga.nosp@m.rino.nosp@m.v@gma.nosp@m.il.c.nosp@m.om

◆ checkValueAndIsNullConsistency()

function mxberry::core::checkValueAndIsNullConsistency ( in  nameStr,
in  valueCVec,
in  isNullCVec,
in  nDimsCVec,
in  isnValueVec 
)

◆ checkvar()

function mxberry::core::checkvar ( in  x,
in  typeSpec,
in  varargin 
)

CHECKVAR checks a generic condition provided by typeSpec string in the following format: 'isnumeric(x)&&isa(x,'int32')||isscalar(x)' etc In case validation fails an exception is thrown.

*  Input:
*    regular:
*        x: anyType[]
*        typeSpec: char[1,]/function_handle - check string in
*            the folowing format: 'isnumeric(x)&&ischar(x)'
*                        OR
*            function_handle[1,1]
* 
*    optional:
*        varName: char[1,] - variable name - used optionally instead of
*            variable name determined auotmatically via inputname(1)
*    properties:
* 
*        errorTag: char[1,] - tag for MException object thrown
*            in case of error. If not specified
*            '<CALLER_NAME>wrongInput' tag is used
* 
*        errorMessage: char[1,] - error message for MException object
*            thrown in case of error. If not specified the message
*            is generated automatically.
* 
*        nCallerStackStepsUp: numeric[1,1] - number of steps up in the call
*            stacks for the caller, by which name the full message tag is to
*            be generated, =1 by default
*  Example:
*    mxberry.core.checkvar(int32(1),@(x)isa(x,'double'),'myVar',. . .
*        'errorTag','wrongInput:badType','errorMessage','Type is wrong')
* 
*    mxberry.core.checkvar([1,2],'iscol(x)','myVar',. . .
*        'errorTag','wrongInput:badType','errorMessage','Type is wrong')
* 
Author
Peter Gagarinov, PhD pgaga.nosp@m.rino.nosp@m.v@gma.nosp@m.il.c.nosp@m.om

◆ combvec()

function mxberry::core::combvec ( in  varargin)

COMBVEC creates a matrix of combinations with elements from input vectors.

*  Usage: indMat=combvec(firstVec,secVec,. . .)
* 
*  Input:
*    optional:
*        firstVec: numeric[1,n1Elems] - first vector
*        . . .
*        lastVec: numeric[1,nKElems] - last vector
* 
*  Output:
*    indMat: numeric[K,nCombs] - matrix with combinations from input vectors
* 
*  Example:
* 
*      firstVec=[1,2,3];
*      secVec=[4,5];
*      indMat=mxberry.core.combvec(firstVec,secVec);
*      indMat
* 
*      indMat =
* 
*           1     2     3     1     2     3
*           4     4     4     5     5     5
* 
Author
Peter Gagarinov, PhD pgaga.nosp@m.rino.nosp@m.v@gma.nosp@m.il.c.nosp@m.om

◆ createarray()

function mxberry::core::createarray ( in  varargin)
Author
Peter Gagarinov, PhD pgaga.nosp@m.rino.nosp@m.v@gma.nosp@m.il.c.nosp@m.om

◆ filesep()

function mxberry::core::filesep ( )

◆ genfilename()

function mxberry::core::genfilename ( in  inpStr)

GENFILENAME generates a valid file name based on a given string.

Author
Peter Gagarinov, PhD pgaga.nosp@m.rino.nosp@m.v@gma.nosp@m.il.c.nosp@m.om

◆ genteststruct()

function mxberry::core::genteststruct ( in  inpNum)

GENTESTSTRUCT generates a complex test structure using input number to guarantee a uniqueness.

*  Input:
*    regular:
*        inpNum: numeric[1,1] - input number
* 
*  Output:
*    Data: struct[1,1] - resulting structure
* 
Author
Peter Gagarinov, PhD pgaga.nosp@m.rino.nosp@m.v@gma.nosp@m.il.c.nosp@m.om

◆ getcallername()

function mxberry::core::getcallername ( in  nStepsUp,
in  mode 
)

GETCALLERNAME returns a name of caller determined by a number of steps up in the call stacks.

*  Input:
*    optional:
*        nStepsUp: numeric[1,1] - number of steps up in the call stacks,
*            =1 by default
*        mode: char [1,] - may be
*            'default' (default) - callerName equals to the class name in
*                the case of class, otherwise callerName equals to the name
*                of the corresponding function or script
*            'full' - callerName equals either to the name of the
*                corresponding function or script or to the name of class
*                concatenated through '.' with the name of method
* 
*  Output:
*    callerName: char[1,] - caller name
* 
Author
Peter Gagarinov, PhD pgaga.nosp@m.rino.nosp@m.v@gma.nosp@m.il.c.nosp@m.om

◆ getcallernameext()

function mxberry::core::getcallernameext ( in  indStack)

GETCALLERNAME determines function/script name or method name of caller together with class name in the case it is method of class for element of stack given by its index (this index is 1 for immediate caller of this function)

*  Usage: methodName=getcallername() OR
*         [methodName,className]=getcallername()
*         methodName=getcallername(indStack) OR
*         [methodName,className]=getcallername(indStack)
* 
*  input:
*    optional:
*      indStack: double [1,1] - index of function/script or method in the
*          stack (this index is 1 for immediate caller of this function); by
*          default equals to 1 (i.e. immediate caller of this function)
*  output:
*    regular:
*      methodName: char - name of function/script or method
*      className: char - empty if it is not a method of some class,
*         otherwise name of the corresponding class
* 
*  Note: 1) In the case a caller is a method of some class, className
*           contains also info on packages, otherwise info on packages is
*           included into methodName. Thus, for example, for method
*           PCAForecast of equivolent.forecast.pca.PCAForecast class we
*           would have:
*             methodName='PCAForecast';
*             className='equivolent.forecast.pca.PCAForecast';
*           If we have function mxberry.core.num2cell, then we would have
*             methodName='mxberry.core.num2cell';
*             className='';
*           The last is true also for scripts.
*        2) In the case a caller is a subfunction of some method or function
*           methodName contains also the whole path to this subfunction, for
*           instance, for subfunction subfunc of function
*           package.subpackage.func we would have:
*             methodName='package.subpackage.func/subfunc';
*             className='';
*           Analogous situation is for scripts and methods of classes.
* 
Author
Peter Gagarinov, PhD pgaga.nosp@m.rino.nosp@m.v@gma.nosp@m.il.c.nosp@m.om

◆ getfirstdimsize()

function mxberry::core::getfirstdimsize ( in  value,
in  nDims 
)

GETFIRSTDIMSIZE returns a size vector for the first N dimensions where N is specified.

*  Input:
*    regular:
*        value: array[] - input value
*        nDims: numeric[1,1] -
* 
*  Output:
*    sizeVec: double[1,nDims] - vector of input value sizes for the first
*       nDims dimensions
* 
Author
Peter Gagarinov, PhD pgaga.nosp@m.rino.nosp@m.v@gma.nosp@m.il.c.nosp@m.om

◆ hash()

function mxberry::core::hash ( in  inpArr,
in  methodName 
)

OBJECTHASH counts the hash of input object/array.

*  Usage: hashVec=objecthash(inpArr)
* 
*  Input:
*    regular:
*        inpArr: any[] - input array of practically arbitrary type
*        methodName: char[1,] - hash calculation method - one of the
*            following methods:'MD2','MD5','SHA-1','SHA-256','SHA-384',
*            'SHA-512'
* 
*  Output:
*    hashVec: char[1,] -  hash of the input object.
* 
Author
Peter Gagarinov, PhD pgaga.nosp@m.rino.nosp@m.v@gma.nosp@m.il.c.nosp@m.om

◆ hashinner()

function mxberry::core::hashinner ( in  inpArr,
in  meth 
)

HASH - Convert an input variable into a message digest using any of several common hash algorithms.

*  USAGE: h = hash(inpArr,'meth')
* 
*  inpArr  = input variable, of any of the following classes:
*         char, uint8, logical, double, single, int8, uint8,
*         int16, uint16, int32, uint32, int64, uint64
*  h    = hash digest output, in hexadecimal notation
*  meth = hash algorithm, which is one of the following:
*         MD2, MD5, SHA-1, SHA-256, SHA-384, or SHA-512
* 
*  Note:
*        (1) If the input is a string or uint8 variable, it is hashed
*             as usual for a byte stream. Other classes are converted into
*             their byte-stream values. In other words, the hash of the
*             following will be identical:
*                      'abc'
*                      uint8('abc')
*                      char([97 98 99])
*             The hash of the follwing will be different from the above,
*             because class "double" uses eight byte elements:
*                      double('abc')
*                      [97 98 99]
*             You can avoid this issue by making sure that your inputs
*             are strings or uint8 arrays.
*         (2) The name of the hash algorithm may be specified in lowercase
*             and/or without the hyphen, if desired. For example,
*             h=hash('my text to hash','sha256');
*         (3) Carefully tested, but no warranty. Use at your own risk.
*         (4) Michael Kleder, Nov 2005
* 
*  Example:
* 
*      algs={'MD2','MD5','SHA-1','SHA-256','SHA-384','SHA-512'};
*      for n=1:6
*          h=mxberry.core.hash('my sample text',algs{n});
*          disp([algs{n} ' (' num2str(length(h)*4) ' bits):'])
*          disp(h)
*      end
* 
Author
Peter Gagarinov, PhD pgaga.nosp@m.rino.nosp@m.v@gma.nosp@m.il.c.nosp@m.om

◆ ind2submat()

function mxberry::core::ind2submat ( in  sizeVec,
in  indVec 
)

IND2SUBMAT works similarly to the built-in ind2sub function but returns all the indices in a single matrix.

*  Input:
*    regular:
*        sizeVec: numeric[1,nDims]
*        indVec: numeric[nIndices,1]/numeric[1,nIndices]
* 
*  Output:
*    indMat: double[nIndices,nDims] - matrix of subindices, each column
*        corresponds to a separate output of the built-in ind2sub function
* 
Author
Peter Gagarinov, PhD pgaga.nosp@m.rino.nosp@m.v@gma.nosp@m.il.c.nosp@m.om

◆ iscelllogical()

function mxberry::core::iscelllogical ( in  value)
Author
Peter Gagarinov, PhD pgaga.nosp@m.rino.nosp@m.v@gma.nosp@m.il.c.nosp@m.om

◆ iscellnumeric()

function mxberry::core::iscellnumeric ( in  valueArr)

ISCELLNUMERIC returns true for a cell arrays consisting of numeric elements only.

*  Input:
*    regular:
*        valueArr: any[nDim1,. . .,nDimK] - arbitrary array, might not be a
*            cell array
* 
*  Output:
*    isPositive: logical[1,1] - if true, valueArr is composed of numeric
*        elements only
*    isPosElemArr: logicla[nDim1,. . .,nDimK] - contains true values for those
*        elements that correspond to numeric elements in valueArr array
* 
Author
Peter Gagarinov, PhD pgaga.nosp@m.rino.nosp@m.v@gma.nosp@m.il.c.nosp@m.om

◆ iscol()

function mxberry::core::iscol ( in  inpArray)
Author
Peter Gagarinov, PhD pgaga.nosp@m.rino.nosp@m.v@gma.nosp@m.il.c.nosp@m.om

◆ isequalcellelemsize()

function mxberry::core::isequalcellelemsize ( in  value1,
in  value2 
)
Author
Peter Gagarinov, PhD pgaga.nosp@m.rino.nosp@m.v@gma.nosp@m.il.c.nosp@m.om

◆ isequalfirstdimsize()

function mxberry::core::isequalfirstdimsize ( in  firstArr,
in  secArr,
in  nDims 
)

ISEQUALFIRSTDIMSIZE checks if the specified arrays have the same size along the first N dimensions where N is specified.

*  Input:
*    regular:
*        firstArr: any[] - first array of any type
*        secArr: any[] - second array of any type
*        nDims: double[1,1] - number of dimensions
* 
*  Output:
*   isPositive: logical[1,1] - true if the check is successfull
* 
Author
Peter Gagarinov, PhD pgaga.nosp@m.rino.nosp@m.v@gma.nosp@m.il.c.nosp@m.om

◆ isfirstdimsizeasspecified()

function mxberry::core::isfirstdimsizeasspecified ( in  valueArr,
in  sizeVec 
)

ISFIRSTDIMSIZEASSPECIFIED check if an input value have a specified size along the first dimensions.

*  Input:
*   regular:
*       valueArr: any[] - input array of any type
*        sizeVec: numeric[1,nDims] - expected size vec
* 
*  Output:
*    isPositive: logical[1,1] - true if the check is successful
* 
Author
Peter Gagarinov, PhD pgaga.nosp@m.rino.nosp@m.v@gma.nosp@m.il.c.nosp@m.om

◆ ismember()

function mxberry::core::ismember ( in  leftVec,
in  rightVec,
in  varargin 
)

ISMEMBER - ismember implementation for arrays of any type.

*  Usage: [isThereVec,indThereVec]=mxberry.core.ismember(leftVec,. . .
*    rightVec);
* 
*  Input:
*    regular:
*        leftVec: any[nObjectsLeft,1]
*        rightVec: any[nObjectsRight,1]
* 
*  Output:
*    isThereVec: logical[nObjectsLeft,1]
*    indThereVec: double[nObjectsLeft,1]
* 
*  Examples:
* 
*    leftVec={struct('a',1,'b',2)}
*    rightVec={struct('a',2,'b',2); struct('a',111,'g','555')}
*    [isThereVec,indThereVec]=mxberry.core.ismember(leftVec,rightVec,. . .
*        @(x,y)x.a==y.a)
* 
Author
Peter Gagarinov, PhD pgaga.nosp@m.rino.nosp@m.v@gma.nosp@m.il.c.nosp@m.om

◆ ismemberbyfunc()

function mxberry::core::ismemberbyfunc ( in  leftVec,
in  rightVec,
in  fCompare 
)

ISMEMBERBYFUNC - ismember implementation for arrays of any type where an element comparison is performed by a specified function. This function is useful when elements are not sortable i.e. EITHER an implementation of ,,,,, does not define a full order OR there is no an implementation of method that calls these operators.

*  Usage: [isThereVec,indThereVec]=mxberry.core.ismemberbyfunc(leftVec,. . .
*   rightVec,fCompare);
* 
*  Input:
*    regular:
*        leftVec: any[nObjectsLeft,1]/[1,nObjectsLeft]
*        rightVec: any[nObjectsRight,1]/[1,nObjectsRight]
*    optional:
*       fCompare: function_handle[1,1] - an element comparison function,
*           default is @isequaln
* 
*  Output:
*    isThereVec: logical[nObjectsLeft,1]/[1,nObjectsLeft]
*    indThereVec: double[nObjectsLeft,1]/[1,nObjectsLeft]
* 
*  Examples:
* 
*    leftVec={struct('a',1,'b',2)}
*    rightVec={struct('a',2,'b',2); struct('a',111,'g','555')}
*    [isThereVec,indThereVec]=ismemberbyfunc(leftVec,rightVec,@(x,y)x.a==y.a)
* 
Author
Peter Gagarinov, PhD pgaga.nosp@m.rino.nosp@m.v@gma.nosp@m.il.c.nosp@m.om

◆ ismembercellstr()

function mxberry::core::ismembercellstr ( in  leftList,
in  rightList,
in  isHigherIndexUsed 
)

ISMEMBERCELLSTR produces the same results as the built-in function "ismember" looking for the higher index if isHigherIndexUsed =true and lower index if isHigherIndexUsed=false (default)

*  Input:
*    regular:
*        leftList: char[1,]/cell[1,nLeftElems] of char[1,] - list of strings
*        rightList: char[1,]/cell[1,nRightElems] of char[1,] - list of strings
*    optional:
*        isHigherIndexUsed: logical[1,1] - if true, higher index is
*            searched for, lower otherwise (default)
* 
*  Output:
*    isThereVec: logical[1,nLeftElems] - contains true for those elements of
*        aList for which a matching element is found in bList
*    indLocVec: double[1,nLeftElems] - contains indices for those elements of
*        aList for which. . . (see above) and zero otherwise
* 
Author
Peter Gagarinov, PhD pgaga.nosp@m.rino.nosp@m.v@gma.nosp@m.il.c.nosp@m.om

◆ ismemberjoint()

function mxberry::core::ismemberjoint ( in  leftCArr,
in  rightCArr,
in  varargin 
)

ISMEMBERJOINT perform joint ismember operation for two cell arrays.

*  Usage: [isThereVec,indThereVec]=ismemberjoint(leftCArr,rightCArr)
* 
*  Input:
*    regular:
*        leftCArr: cell[n1,. . .,nk] of any[] -cell array of arbitrary size,
*           in the case dim is not given (see below for
*           details) it is assumed that all cells must contain either
*           columns or rows of some type and of the same size (either
*           [1,nLeft] or [nLeft,1]); if dim is given then size of all items
*           in inpCell should be the same (and equal to nLeft) only along
*           dimension equal to dim
*        rightCArr: cell[n1,. . .,nk] of any[] - cell array
*           of the same structure and size as leftCArr which
*           means that types and orientation (rows or columns, if dim is not
*           given) and size along other dimensions that dim (if the latter
*           is given) of respective cells in leftCArr and rightCArr should
*           be the same.
* 
*      Note: empty elements present in both leftCArr and rightCArr on
*             THE SAME PLACES are ignored
* 
*    optional:
*        dim: double [1,1] - main dimension along which ismemberjoint is
*            performed
* 
*        checkSizeIfEmpty: logical[1,1] - if true, then consistency of
*            sizes  of the corresponding cells in leftCArr and rightCArr is
*            performed even in the case one of them is empty along dimension
*            given by dim, if false, this check is omitted; by default it is
*            true
* 
*      Note: For other optional arguments and properties see descriptions of
*        mxberry.core.ismemberrows and mxberry.core.uniquerows functions
*        for their arguments immediately following after isInteger input
*        argument
* 
*  Output:
*    isThereVec: logical[nLeftElem,1]/[1,nLeft] array of membership indicators
*        of all respective elements within leftCArr to all respective
*        elements within rightCArr, nLeftElem is size of arrays contained
*        within leftCArr arrays for dimention dim
*    indThereVec: double[nLeftElem,1]/[1,nLeft]- indices indicating location of
*        respective elements within leftCArr in rightCArr elements
* 
*  Examples:
* 
*    [isThereVec,indThereVec]=ismemberjoint({[1 2],{'a','b'};[3. . .
*        4],{'c','d'}},{[1 2 3],{'a','b','c'};[3 4 5],{'c','d','m'}})
* 
Author
Peter Gagarinov, PhD pgaga.nosp@m.rino.nosp@m.v@gma.nosp@m.il.c.nosp@m.om

◆ ismemberjointwithnulls()

function mxberry::core::ismemberjointwithnulls ( in  leftCVec,
in  leftIsNullCVec,
in  rightCVec,
in  rightIsNullCVec,
in  dim 
)

ISMEMBERJOINTWITHNULLS perform joint ismember operation for two cell arrays for which also cell arrays detemining positions of null values are given.

*  Usage: [isMemberVec,indMemberVec]=ismemberjointwithnulls(. . .
*             leftCVec,leftIsNullCVec,rightCVec,rightIsNullCVec,dim)
* 
*  Input:
*    regular:
*        leftCVec: cell [1,nElems], all cells should contain arrays of
*            arbitrary types with size equal along dimension given by dim -
*            values of elements on the left
*        leftIsNullCVec: cell [1,nElems], i-th cell should contain logical
*            array with number of dimensions nDims_i and of sizes equal with
*            the ones for i-th cell within leftCVec along all dimensions
*            1..max(nDims_i,dim) - logical arrays determining what values are
*            null on the left
*        rightCVec: cell [1,nElems], all cells should contain arrays of
*            arbitrary types with size equal along dimension given by dim -
*            values of elements on the right
*        rightIsNullCVec: cell [1,nElems], i-th cell should contain logical
*            array with number of dimensions nDims_i and of sizes equal with
*            the ones for i-th cell within rightCVec along all dimensions
*            1..max(nDims_i,dim) - logical arrays determining what values are
*            null on the right
*    optional:
*        dim: double[1,1] - main dimension along which ismemberjointwithnulls
*            is performed; if not given, dim is taken equal to 1
*  Output:
*    isMemberVec: logical [nLeftElem,1] - array of membership indicators
*        of all respective elements within leftCVec (with taking into
*        account of leftIsNullCVec) to all respective elements within
*        rightCVec (with taking into account of rightIsNullCVec),
*        nLeftElem is size of arrays contained within leftCVec (and
*        leftIsNullCVec) arrays for dimention dim
*    indMemberVec: double [nLeftElem,1] - indices indicating location of
*        respective elements within leftCVec (with taking into account of
*        leftIsNullCVec) in rightCVec elements (with taking into account
*        of rightIsNullCVec)
* 
*  Example: [isMemberVec,indMemberVec]=ismemberjointwithnulls(. . .
*               {[1;2;1;2],{'a';'b';'c';'a'}},. . .
*               {[true;true;false;true],[true;true;true;false]},. . .
*               {[1;2;3],{'a';'b';'c'}},. . .
*               {[true;true;false],[true;true;true]},1);
* 
Author
Peter Gagarinov, PhD pgaga.nosp@m.rino.nosp@m.v@gma.nosp@m.il.c.nosp@m.om

comparison may be done even if sizes of corresponding elements on left
and right sides are not equal along additional dimensions

◆ ismemberrows()

function mxberry::core::ismemberrows ( in  inpLeftMat,
in  inpRightMat,
in  isInteger,
in  forceMode 
)

ISMEMBERROWS finds indices of rows from the first matrix in the second matrix, i.e. it is the more efficient version of ISMEMBER(. . .,'rows')

*  Usage: [isMemberVec,indMemberVec]=ismemberrows(inpLeftMat,inpRightMat)
* 
*  Input:
*    regular:
*        inpLeftMat: double/logical/char[nLeftRows,nCols] - first matrix
*        inpRightMat: double/logical/char[nRightRows,nCols] - second matrix
*    optional:
*       isInteger: logical[1,1] - if true then no checks that inpLeftMat and
*            inpRightMat contain finite integer values are performed
*        forceMode: char[1,] - if given, then determines mode to be used,
*            may be 'standard' (in this case built-in version is forced to
*          be used) or 'optimized' (then optimized version is to be used
*          instead of built-in one in the case it is possible)
*  Output:
*    isMemberVec: logical [nLeftRows,1] - whether corresponding row from
*        inpLeftMat equals to some row in matrix inpRightMat
*    indMemberVec: double [nLeftRows,1] - indices of corresponding rows
*        from inpLeftMat in matrix inpRightMat (0 if there is no equal row in b)
* 
Author
Peter Gagarinov, PhD pgaga.nosp@m.rino.nosp@m.v@gma.nosp@m.il.c.nosp@m.om

◆ ismembersortableobj()

function mxberry::core::ismembersortableobj ( in  firstVec,
in  secVec 
)

ISMEMBER implementation strictly for sortable entities i.e. for those that have 1) full order defined by implementation of comparison operators /isequal/isequaln/isequaln, , , , , 2) an implementation of method that uses these operators.

*  Usage: [isThereVec,indThereVec]=. . .
*    mxberry.core.ismembersortableobj(leftVec,rightVec);
* 
*  Input:
*    regular:
*        leftVec: any[nObjectsLeft,1]
*        rightVec: any[nObjectsRight,1]
* 
*  Output:
*    isThereVec: logical[nObjectsLeft,1]
*    indThereVec: double[nObjectsLeft,1]
* 
Author
Peter Gagarinov, PhD pgaga.nosp@m.rino.nosp@m.v@gma.nosp@m.il.c.nosp@m.om

◆ isrow()

function mxberry::core::isrow ( in  inpArray)
Author
Peter Gagarinov, PhD pgaga.nosp@m.rino.nosp@m.v@gma.nosp@m.il.c.nosp@m.om

◆ isunique()

function mxberry::core::isunique ( in  inpVec)
Author
Peter Gagarinov, PhD pgaga.nosp@m.rino.nosp@m.v@gma.nosp@m.il.c.nosp@m.om

◆ isvalidsize()

function mxberry::core::isvalidsize ( in  varargin)

ISVALIDSIZE compares size of input arrays with size mask. Size mask can contain nans that allow any size for a corresponding dimension. Function automatically adds 1 at the end of size. For example, array 3x2 is also array 3x2x1 and 3x2x1x1x1 e.t.c;.

*  Usage isValid=isvalidsize(firstArr,secArr,lastArr,sizeVec);
* 
*  Input:
*    regular:
*        firstArr: any[]
*        secArr: any[]
*        . . .. . .
*        lastArr: any[]
*        sizeVec: double[1,nDims] - mask for check of size, can contain
*            nans that mean that a corresponding dimension's size is ignored
* 
*  Output:
*    isValidVec: logical[1,N] - true if corresponding array is proper with
*        mask
* 
Author
Peter Gagarinov, PhD pgaga.nosp@m.rino.nosp@m.v@gma.nosp@m.il.c.nosp@m.om

◆ isvar()

function mxberry::core::isvar ( in  varName)
Author
Peter Gagarinov, PhD pgaga.nosp@m.rino.nosp@m.v@gma.nosp@m.il.c.nosp@m.om

◆ isvec()

function mxberry::core::isvec ( in  inpArray)
Author
Peter Gagarinov, PhD pgaga.nosp@m.rino.nosp@m.v@gma.nosp@m.il.c.nosp@m.om

◆ num2cell()

function mxberry::core::num2cell ( in  inpArray,
in  varargin 
)

NUM2CELL is an extension of Matlab built-in function "num2cell" designed to work correctly with empty arrays (such as zero(10,0)) for instance.

*  Input and Output arguments are the same as for built-in num2cell function
* 
Author
Peter Gagarinov, PhD pgaga.nosp@m.rino.nosp@m.v@gma.nosp@m.il.c.nosp@m.om

◆ parseparams()

function mxberry::core::parseparams ( in  args,
in  propNameList,
in  nRegExpected,
in  nPropExpected 
)

PARSEPARAMS behaves exactly as a built-in Matlab function apart from the incorrect behavior of Matlab function in cases when the regular argument has a character type. Additionally the function allows to avoid a misinterpretation of symbolical values of regular parameters via listing all the allowed properties.

*  Input:
*    regular:
*        arg: cell[1,] list of input parameters to parse
* 
*    optional:
*        propNameList: cell[1,] of char[1,] - list of properties to recognize
*            this parameter can be useful for confusing the symbolical regular
*            arguments with the properties. For instance, if a character
*            value 'alpha' is expected to be recognized as a regular
*            parameter one can just list all the properties in propNameList
*            not including 'alpha' in the list.
* 
*          Note: property names are case-insensitive!
* 
*        nRegExpected: numeric[1,1]/[1,2] - an expected number of regular
*           arguments/range of regular argument numbers. If the actual
*           number doesn't mach the expected number an exception is thrown.
* 
*        nPropExpected: numeric[1,1] - an expected number of properties
* 
*  Output:
*    reg: cell[1,nRegs] - list of regular arguments
*    prop: cell[1,nProps*2] - list of property name-value pairs
* 
Author
Peter Gagarinov, PhD pgaga.nosp@m.rino.nosp@m.v@gma.nosp@m.il.c.nosp@m.om

◆ parseparext()

function mxberry::core::parseparext ( in  args,
in  propNameValMat,
in  varargin 
)

PARSEPAREXT behaves in the same way as mxberry.core.parseparams but returns property values in a more convenient form.

*  Input:
*    regular:
*        arg: cell[1,] list of input parameters to parse
*        propNameValMat: cell[1-3,nExpProps] of char[1,]/cell[2,]
*            - list of properties to recognize
*            - and optionally the list of default values for properties
*            - and optionally the list of check strings for properties
*                (see mxberry.core.check.checkgen for check string
*                    syntax)
* 
*          Note: property names are case-insensitive!
* 
*    optional:
*        nRegExpected: numeric[1,1]/[1,2] - an expected number of regular
*           arguments/range of regular argument numbers. If the actual
*           number doesn't mach the expected number an exception is thrown.
* 
*        nPropExpected: numeric[1,1] - an expected number of properties
* 
*    properties:
*        regCheckList: cell[1,nRegMax] of char[1,] - list of regular
*            parameter check strings
* 
*        regDefList: cell[1,nRegMax] of any[] - list of regular parameter
*           values
* 
*        propRetMode: char[1,] - property return mode, the following modes
*            are supported
*                'list' - an aggregated list of specified properties
*                    is  returned instead of returning each property as
*                    a separate  output
*                'separate' - each property is returned separately followed
*                    isSpec indicator, this is a default method
* 
*        isObligatoryPropVec: logical[1,nExpProp] - indicates whether a
*            corresponding property from propNameValMat is obligatory. This
*            property can only be used when propNameValMat is not empty
* 
*        isDefaultPropSpecVec: logical[1,nExpProp] - indicates whetehr a
*            corresponding property has a default value. This property can
*            only be used when propRetMode='list'. Properties without
*            default values are not included into the resulting list
* 
*  Output:
*    reg: cell[1,nRegs] - list of regular parameters
* 
*    isRegSpecVec: logical[1,nRegs] - indicates whether a regular argument
*        specified
* 
*    ---------------"list" mode -----------------
*    prop: cell[1,nFilledProps]
*    isPropSpecVec: logical[1,nExpProps]
* 
*    ---------------"separate" mode
*    prop1Val: any[] - value of the first property specified by propNameValMat
*        . . .
*    propNVal: any[] - value of the last property specified by propNameValMat
* 
*    isProp1Spec: logical[1,1] - indicates whether the first property is
*        specified
*        . . .
*    isPropNSpec: logical[1,1] - indicates whether the last property is
*        specified
* 
*  Example:
*    [reg,isSpecVec,. . .
*        propVal1,propVal2,propVal3. . .
*        isPropVal1,isPropVal2,isPropVal3]=. . .
*        mxberry.core.parseparext({1,2,'prop1',3,'prop2',4},. . .
*        {'prop1','prop2','prop3';. . .
*        [],[],5;. . .
*        'isscalar(x)','isscalar(x)','isnumeric(x)'},. . .
*        [0 3],. . .
*        'regDefList',{1,2,3},. . .
*        'regCheckList',{'isnumeric(x)','isscalar(x)','isnumeric(x)'},. . .
*        'isObligatoryPropVec',[true true false])
* 
*  reg =   {1,2,3}
*  isSpecVec = [true,true,false]
*  propVal1 = 3
*  propVal2 = 4
*  propVal3 = 5
*  isPropVal1 =true
*  isPropVal2 =true
*  isPropVal3 =false
* 
Author
Peter Gagarinov, PhD pgaga.nosp@m.rino.nosp@m.v@gma.nosp@m.il.c.nosp@m.om

◆ parsestackelem()

function mxberry::core::parsestackelem ( in  SStackElem)

PARSESTACKELEM parses structure for given element of stack and returns the corresponding function/script name or method name together with class name in the case the element corresponds to some method of class.

*  Usage: methodName=parsestackelem(SStackElem) OR
*         [methodName,className]=parsestackelem(SStackElem)
* 
*  input:
*    regular:
*      SStackElem: struct [1,1] - structure with the same fields as those
*          that are given by dbstack (see info for dbstack for details)
*  output:
*    regular:
*      methodName: char - name of function/script or method
*      className: char - empty if it is not a method of some class,
*         otherwise name of the corresponding class
* 
*  Note: 1) In the case an element corresponds to a method of some class,
*           className contains also info on packages, otherwise info on
*           packages is included into methodName. Thus, for example, for
*           method PCAForecast of equivolent.forecast.pca.PCAForecast class
*           we would have:
*             methodName='PCAForecast';
*             className='equivolent.forecast.pca.PCAForecast';
*           If we have function mxberry.core.num2cell, then we would have
*             methodName='mxberry.core.num2cell';
*             className='';
*           The last is true also for scripts.
*        2) In the case an element corresponds to a subfunction of some
*           method or function methodName contains also the whole path to
*           this subfunction, for instance, for subfunction subfunc of
*           function package.subpackage.func we would have:
*             methodName='package.subpackage.func/subfunc';
*             className='';
*           Analogous situation is for scripts and methods of classes.
* 
Author
Peter Gagarinov, PhD pgaga.nosp@m.rino.nosp@m.v@gma.nosp@m.il.c.nosp@m.om,
Ilya Roublev, PhD iroub.nosp@m.lev@.nosp@m.gmail.nosp@m..com

◆ repmat()

function mxberry::core::repmat ( in  inpArray,
in  varargin 
)
Author
Peter Gagarinov, PhD pgaga.nosp@m.rino.nosp@m.v@gma.nosp@m.il.c.nosp@m.om

◆ roundn()

function mxberry::core::roundn ( in  inpArr,
in  indexExp 
)

ROUNDN rounds to multiple of 10^indexExp.

*  Input:
*    regular:
*        inpArr: numeric[n1,. . .,nk] - input real array
*        indexExp: numeric[1,1] - index exponent
*  Output:
*    outArr: numeric[n1,. . .,nk] - array with rounded values
* 
Author
Peter Gagarinov, PhD pgaga.nosp@m.rino.nosp@m.v@gma.nosp@m.il.c.nosp@m.om

◆ smartcat()

function mxberry::core::smartcat ( in  xArray,
in  yArray 
)

◆ structhash()

function mxberry::core::structhash ( in  structB,
in  methodName 
)

◆ subreffrontdim()

function mxberry::core::subreffrontdim ( in  inpArray,
in  curInd 
)
Author
Peter Gagarinov, PhD pgaga.nosp@m.rino.nosp@m.v@gma.nosp@m.il.c.nosp@m.om

◆ throwerror()

function mxberry::core::throwerror ( in  msgTag,
in  varargin 
)

THROWERROR works similarly to built-in ERROR function in case when there is no output arguments but simpler to use as it automatically generates tags based on caller name When output argument is specified an exception object is returned instead.

*  Input:
*    regular:
*        msgTag: char[1,] error tag suffix which is complemented by
*            automatically generated part
*        . . .
*        same inputs as in error function
*        . . .
*    properties:
*        nCallerStackStepsUp: numeric[1,1] - number of steps up in the call
*            stacks for the caller, by which name the full message tag is to
*            be generated, =1 by default
* 
*  Output:
*    optional: meObj: MException[1,1]
* 
Author
Peter Gagarinov, PhD pgaga.nosp@m.rino.nosp@m.v@gma.nosp@m.il.c.nosp@m.om

◆ throwwarn()

function mxberry::core::throwwarn ( in  msgTag,
in  varargin 
)

THROWWARN works similarly to built-in WARNING function in case when there is no output arguments but simpler to use as it automatically generates tags based on caller name When output argument is specified an exception object is returned instead.

*  Input:
*    regular:
*        msgTag: char[1,] error tag suffix which is complemented by
*            automatically generated part
*        . . .
*        same inputs as in error function
*        . . .
* 
Author
Peter Gagarinov, PhD pgaga.nosp@m.rino.nosp@m.v@gma.nosp@m.il.c.nosp@m.om

◆ unionjoint()

function mxberry::core::unionjoint ( in  leftCell,
in  rightCell 
)

UNIONJOINT calculates union of corresponding elements of two cell arrays jointly accross all cell array elements.

*  Usage: [unionCell,indLeft,indRight,indLocLeftVec,indLocRightVec]=unionjoint(leftCell,rightCell)
* 
*  Input:
*    regular:
*        leftCell: cell [n_1,n_2,. . .,n_k] - first cell array
* 
*        rightCell: cell [n_1,n_2,. . .,n_k] - second cell array
* 
*  Output:
*    unionCell: cell [n_1,n_2,. . .,n_k] - resulting cell array
* 
*    indLeft: double [1,m_1] - indices of corresponding elements of leftCell
*       within unionCell
* 
*    indRight: double [1,m_2] - indices of corresponding elements of
*       rightCell in unionCell
* 
*    indLocLeftVec: double[1,max(m_1,m_2)] - for each element of unionCell
*        contains indices of elements of leftCell or zero otherwise
* 
*    indLocRightVec: double[1,max(m_1,m_2)] - for each element of unionCell
*        contains indices of elements of rightCell or zero otherwise
* 
Author
Peter Gagarinov, PhD pgaga.nosp@m.rino.nosp@m.v@gma.nosp@m.il.c.nosp@m.om

%

◆ unique()

function mxberry::core::unique ( in  inpVec)

UNIQUE for arrays of any type.

*  Usage: [outUnqVec,indRightToLeftVec,indLeftToRightVec]=. . .
*    mxberry.core.unique(inpVec);
* 
*  Input:
*    regular:
*      inpVec: cell[nObjects,1]/[1,nObjects] of objects
* 
*  Output:
*    outUnqVec: cell[nUniqObjects,1]/[1,nUniqObjects]
*    indRightToLeftVec: double[nUniqObjects,1] : all
*        fCompare(inpVec(indRightToLeftVec)==outUnqVec)==true
*    indLeftToRightVec: double[nObjects,1] : all
*        all(fCompare(outUnqVec(indLeftToRightVec)==inpVec))
* 
Author
Peter Gagarinov, PhD pgaga.nosp@m.rino.nosp@m.v@gma.nosp@m.il.c.nosp@m.om

◆ uniquebyfunc()

function mxberry::core::uniquebyfunc ( in  inpVec,
in  fCompare,
in  algoName 
)

UNIQUEBYFUNC unique for arrays of any type where an element comparison is performed by a specified function.

*  Usage: [outUnqVec,indRightToLeftVec,indLeftToRightVec]=uniquebyfunc(. . .
*            inpVec,fCompare);
* 
*  Input:
*    regular:
*        inpVec: any[nObjects,1] - input vector of objects
*    optional:
*        fCompare: function_handle[1,1] - an element comparison function,
*            default is @isequaln
*        algoName: char[1,] - can be one of
*            'memhungry' - faster but requires more RAM
*            'mempreserve' (DEFAULT) - RAM preserving but slower
* 
*  Output:
*    outUnqVec: cell[nUniqObjects,1]
*    indRightToLeftVec: double[nUniqObjects] : all
*        fCompare(inpVec(indRightToLeftVec)==outUnqVec)==true
*    indLeftToRightVec: double[nObjects,1] : all
*        all(fCompare(outUnqVec(indLeftToRightVec)==inpVec))
* 
Author
Peter Gagarinov, PhD pgaga.nosp@m.rino.nosp@m.v@gma.nosp@m.il.c.nosp@m.om

◆ uniquejoint()

function mxberry::core::uniquejoint ( in  inpCArr,
in  varargin 
)

UNIQUEJOINT perform joint unique operation for cell arrays.

*  Usage: [uniqueCell,indRight2LeftVec,indLeft2RightVec]=uniquejoint(inpCell)
* 
*  Input:
*    regular:
*        inpCArr: cell [n_1,n_2,. . .,n_k] - cell array;
*           in the case dim is not given (see below for details) it is
*           assumed that size of all items in inpCell should be the same
*           (either [1,nInp] or [nInp,1]); if dim is given then size of all
*           items in inpCell should be the same only along dimension equal
*           to dim
*    optional:
*        dim: double [1,1] - main dimension along which uniquejoint is
*            performed
* 
*        For other optional arguments and properties see description of
*        mxberry.core.uniquerows function for its arguments immediately
*        following after isInteger input argument
* 
*  Output:
*    uniqueCell: cell[n_1,n_2,. . .,n_k] - cell array of the same size and
*        structure as inpCell but with shrinked items
* 
*    indRight2LeftVec: double[nUnique,1] - indices such that
*        uniqueCell=cellfun(@(x)x(indRight2LeftVec),inpCell,. . .
*            'UniformOutput',false)
*        if dim is not given, otherwise, for example, if dim=1, then
*        uniqueCell=cellfun(@(x)reshape(x(indRight2LeftVec,:),[. . .
*            numel(indRight2LeftVec) subsref(size(x),. . .
*            struct('type','()','subs',{{2:ndims(x)}}))]),inpCell,. . .
*            'UniformOutput',false)
* 
*    indLeft2RightVec: double[nInp,1] - indices such that
*        inpCell=cellfun(@(x)x(indLeft2Right),uniqueCell,. . .
*            'UniformOutput',false)
*        if dim is not given, otherwise, for example, if dim=1, then
*        inpCell=cellfun(@(x)reshape(x(indLeft2RightVec,:),[. . .
*            numel(indLeft2RightVec) subsref(size(x),. . .
*            struct('type','()','subs',{{2:ndims(x)}}))]),uniqueCell,. . .
*            'UniformOutput',false)
* 
*    isSorted: logical [1,1] - determines whether values in uniqueCell are
*        sorted or not; this function tries always to sort all values
*        in ascending order if it is possible jointly for all cells; if this
*        is possible then isSorted is true, otherwise isSorted is false and
*        hence there are some cells whose values are not sortable
* 
*  Examples:
* 
*      [uniqueCell,indRight2LeftVec,indLeft2RightVec]=. . .
*          uniquejoint({[1 2 1]; {'a','b','a'}})
*      [uniqueCell,indRight2LeftVec,indLeft2RightVec]=. . .
*          uniquejoint({[1 2;2 3;1 2],cat(3,{'a','c';'b','d';'a';'c'}. . .
*          {'e','f';'f','g';'e','f'}))
* 
Author
Peter Gagarinov, PhD pgaga.nosp@m.rino.nosp@m.v@gma.nosp@m.il.c.nosp@m.om

TODO allow for cells containing 1-dimentional double arrays the same
size - unique(..,'rows') can be used for this case

◆ uniquerows()

function mxberry::core::uniquerows ( in  inpMat,
in  isInteger,
in  forceMode 
)

UNIQUEROWS finds unique rows in input matrix, i.e. the more effective version of UNIQUE(. . .,'rows')

*  Usage: [uniqueMat,indRight2LeftVec,indLeft2RightVec]=uniquerows(inpMat)
* 
*  Input:
*   regular:
*       inpMat: double/logical/char [nRows,nCols] - input matrix
*    optional:
*        isInteger: logical [1,1] - if true then no checks that inpMat contain
*           finite integer values are performed
*        forceMode: char [1,] - if given, then determines mode to be used,
*           can take the following values:
*                'standard' (in this case built-in version is forced to
*                    be used)
*                'optimized' (then optimized version is to be used
*                    instead of built-in one in the case it is possible)
*  Output:
*    uniqueMat: double/logical/char [nUniqueRows,nCols] - output
*        matrix with unique rows
*    indRight2LeftVec: double [nUniqueRows,1] - indices such that
*        uniqueMat coincides with inpMat(indRight2LeftVec,:)
*    indLeft2RightVec: double [nRows,1] - indices such that
*        uniqueMat(indLeft2RightVec,:) coincides with inpMat
* 
Author
Peter Gagarinov, PhD pgaga.nosp@m.rino.nosp@m.v@gma.nosp@m.il.c.nosp@m.om

◆ uniquesortableobj()

function mxberry::core::uniquesortableobj ( in  inpVec)

UNIQUE implementation strictly for sortable entities i.e. for those that have 1) full order defined by implementation of comparison operators /isequal/isequaln/isequaln, , , , , 2) an implementation of method that uses these operators.

*  Usage: [outUnqVec,indRightToLeftVec,indLeftToRightVec]=. . .
*    mxberry.core.uniquesortableobj(inpVec,fCompare);
* 
*  Input:
*    regular:
*      inpVec: cell[nObjects,1]/[1,nObjects] of objects
* 
*  Output:
*    outUnqVec: cell[nUniqObjects,1]/[1,nUniqObjects]
*    indRightToLeftVec: double[nUniqObjects,1] : all
*        fCompare(inpVec(indRightToLeftVec)==outUnqVec)==true
*    indLeftToRightVec: double[nObjects,1] : all
*        all(fCompare(outUnqVec(indLeftToRightVec)==inpVec))
* 
Author
Peter Gagarinov, PhD pgaga.nosp@m.rino.nosp@m.v@gma.nosp@m.il.c.nosp@m.om