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

Namespaces

 test
 

Classes

class  AStructChangeTracker
 
class  StructChangeTracker
 STRUCTCHANGETRACKER keeps a list of structure patches and provide tools for applying them to any arbitrary structure. Patches can be defined either as static or plain class methods A method must 1) have 'patch_' prefix and '_#' suffix 2) be public to be recognized as patch. More...
 
class  StructChangeTrackerEmptyPlug
 STRUCTCHANGETRACKEREMPTYPLUG is an empty impementation of ASTRUCTCHANGETRACKER interface. More...
 
class  StructDisp
 This class is responsible for displaying structure outline. More...
 

Functions

function binaryunionstruct (in leftStruct, in rightStruct, in fieldOpCell, in leftFieldOpCell, in rightFieldOpCell)
 BINARYUNIONSTRUCT applies a set of binary operations to the fields of two structures, each operation can return multiple results. More...
 
function updaterescell ()
 
function binarynotdefined (in varargin)
 
function auxcheckfuncell (in fieldOpCell)
 
function fieldfilterstruct (in InpStruct, in field2KeepList, in isCheckField)
 FIELDFILTERSTRUCT leaves in input structure array only specified fields. More...
 
function getleavelist (in SInp)
 GETLEAVELIST generates a list of structure leave paths. More...
 
function getleavelistint (in SInp)
 
function pathfilterstruct (in InpStruct, in path2KeepList)
 PATHFILTERSTRUCT leaves in input structure array only specified paths. More...
 
function auxgetfieldstruct (in SInp, in fieldName)
 
function sepcell2pathlist (in sepCell)
 
function strucdisp (in varargin)
 STRUCDISP display structure outline. More...
 
function struct2str (in SInp, in varargin)
 STRUCDISP display structure outline. More...
 
function structapplypath (in structB, in path, in value)
 STRUCTAPPLYPATH for given a path '.a.b.c.d.' and a value and a structB, returns modified structB, so that structB.a.b.c.d==value;. More...
 
function structcheckpath (in SInpArr, in pathStr)
 STRUCTCHECKPATH for a given path ('a.b.c.d.' or {'a','b','c','d'} and a structure array SInpArr returns true, if this path exists for all structure array elements on any nesting level. More...
 
function structcompare (in SX, in SY, in absTol, in relTol)
 STRUCTCOMPARE compares two structures using the specified tolerance. More...
 
function structcomparevec (in SX, in SY, in absTol, in relTol)
 STRUCTCOMPARE compares two structures using the specified tolerance. More...
 
function structcompare1darray (in SX, in SY, in absTol, in relTol)
 STRUCTCOMPARE1D compares 1-dimentional structural arrays. More...
 
function structcomparescalar (in SX, in SY, in absTol, in relTol)
 STRUCTCOMPARE1D compares the scalar structures. More...
 
function compfun (in x, in y, in absTol, in relTol)
 COMPFUN compares two different objects (ideally - of any type) More...
 
function toNumericSupportingMinus (in x)
 
function structgetpath (in SInpArr, in pathStr, in isPresenceChecked, in isJustCheck)
 STRUCTGETPATH extract a value from a given structure array using a path specified either as a string or as a sequence of field names separated by dots. It is assumed that all values located at the specified path are of the same size. More...
 
function getField (in SInpArr, in fieldName, in isPresenceChecked)
 
function unionstructsalongdim (in catDimension, in varargin)
 UNIONSTRUCTS unites structures with the same fields by concatenating the corresponding fields along the specified dimension. More...
 
function updateleaves (in SData, in fUpdateFunc)
 UPDATELEAVES applies the specified function to each structure leave value and returns the updated structure. More...
 
function fUpdateExtFunc (in val, in path)
 
function updateleavesext (in SData, in fUpdateFunc)
 UPDATELEAVESEXT applies the specified function to each structure leave value and returns the updated structure, potentially with changed field paths. More...
 
function setSDataField (in subFieldNameList, in value)
 

Function Documentation

◆ auxcheckfuncell()

function mxberry::core::struct::auxcheckfuncell ( in  fieldOpCell)

◆ auxgetfieldstruct()

function mxberry::core::struct::auxgetfieldstruct ( in  SInp,
in  fieldName 
)

◆ binarynotdefined()

function mxberry::core::struct::binarynotdefined ( in  varargin)

◆ binaryunionstruct()

function mxberry::core::struct::binaryunionstruct ( in  leftStruct,
in  rightStruct,
in  fieldOpCell,
in  leftFieldOpCell,
in  rightFieldOpCell 
)

BINARYUNIONSTRUCT applies a set of binary operations to the fields of two structures, each operation can return multiple results.

*  Usage:
*    [S1,S2,S3,. . .,Sn]=binaryunionstruct(leftStruct,rightStruct,. . .
*        fieldOpCell,leftFieldOpCell,rightFieldOpCell)
* 
*  Input:
*    regular:
*        leftStruct: struct[n1,n2,. . .,nk] - first input structure array
* 
*        rightStruct: struct[n1,n2,. . .,nk] - second input structure array
* 
*        fieldOpCell: cell[1,nOps] - cell array of operations applied
*           to common fileds of two structures, each operation should return
*              n arguments
* 
*    optional:
* 
*        leftFieldOpCell: cell[1,nOps] - cell array of operations that
*           applied to the fields that are present only in the first
*              structure, each operation should return n arguments
* 
*                default value: @deal
* 
*        rightFieldOpCell: cell[1,nOps] - cell array of operations that
*           applied to the fields that are present only in the second
*           structure, each operation should return n arguments
* 
*                default value: @deal
* 
*  Output:
*    S1: struct [n1,n2,. . .,nk,nOps] - contains the first outputs from operations
*    S2: struct [n1,n2,. . .,nk,nOps] - contains the second outputs from operations
*    . . .
*    Sn: struct [n1,n2,. . .,nk,nOps] - contains n'th outputs from operatons
* 
Author
Peter Gagarinov, PhD pgaga.nosp@m.rino.nosp@m.v@gma.nosp@m.il.c.nosp@m.om

◆ compfun()

function mxberry::core::struct::compfun ( in  x,
in  y,
in  absTol,
in  relTol 
)

COMPFUN compares two different objects (ideally - of any type)

◆ fieldfilterstruct()

function mxberry::core::struct::fieldfilterstruct ( in  InpStruct,
in  field2KeepList,
in  isCheckField 
)

FIELDFILTERSTRUCT leaves in input structure array only specified fields.

*  Usage: ResStruct=fieldfilterstruct(InpStruct,field2KeepList)
* 
*  input:
*    regular:
*        mandatory:
*            inpStruct: struct[multydimensional] - struct array;
*            field2KeepList: cell[1,nFields] - names of fields to leave;
*        optional:
*            isCheckField: logical[1] - if it is true all names from
*                    field2KeepList have to be names of fields from
*                    InpStruct or function displays error message;
*                    by default false;
*  output:
*    regular:
*       ResStruct: struct[multydimensional] - struct array of the same size
*                as inpStruct;
* 
*  Example:  ResStruct=fieldfilterstruct(InpStruct,{'a','b'})
* 
Author
Peter Gagarinov, PhD pgaga.nosp@m.rino.nosp@m.v@gma.nosp@m.il.c.nosp@m.om

◆ fUpdateExtFunc()

function mxberry::core::struct::fUpdateExtFunc ( in  val,
in  path 
)

◆ getField()

function mxberry::core::struct::getField ( in  SInpArr,
in  fieldName,
in  isPresenceChecked 
)

◆ getleavelist()

function mxberry::core::struct::getleavelist ( in  SInp)

GETLEAVELIST generates a list of structure leave paths.

*  Input:
*    regular:
*        SInp: struct[] - input structure array
* 
*  Output:
*    pathSpecList: cell[nPaths,1] of cell[1,] of char[1,]/cell[1,] of double[1,]
* 
*        - list of path specifications in the following form:
*            {{ind11,ind12,. . .,ind1n1},field1,. . .
*                {ind21,ind22,. . .,ind2n2},field2,. . .
*                {ind31,ind32,. . .,ind3n3},field3}
*                which corresponds to
*            S(ind11,ind12,. . .,ind1n1).field1(. . .
*                ind21,ind22,. . .,ind2n2).field2(. . .
*                ind31,ind32,. . .,ind3n3).field3
* 
*   valueList: cell[nPaths,1] of any[] - list of leave  values
* 
Author
Peter Gagarinov, PhD pgaga.nosp@m.rino.nosp@m.v@gma.nosp@m.il.c.nosp@m.om

◆ getleavelistint()

function mxberry::core::struct::getleavelistint ( in  SInp)

◆ pathfilterstruct()

function mxberry::core::struct::pathfilterstruct ( in  InpStruct,
in  path2KeepList 
)

PATHFILTERSTRUCT leaves in input structure array only specified paths.

*  Usage: ResStruct=pathfilterstruct(InpStruct,field2KeepList)
* 
*  Input:
*    regular:
*        InpStruct: struct array
*        path2KeepList: cell[1,nPaths] - cell array of strings with paths in
*                structure;
*  Output:
*    regular:
*        ResStruct: struct array
* 
*  Example:  ResStruct=pathfilterstruct(InpStruct,{'a','a.b','cd.u','.m'})
* 
Author
Peter Gagarinov, PhD pgaga.nosp@m.rino.nosp@m.v@gma.nosp@m.il.c.nosp@m.om

◆ sepcell2pathlist()

function mxberry::core::struct::sepcell2pathlist ( in  sepCell)

◆ setSDataField()

function mxberry::core::struct::setSDataField ( in  subFieldNameList,
in  value 
)

◆ strucdisp()

function mxberry::core::struct::strucdisp ( in  varargin)

STRUCDISP display structure outline.

*  Usage: STRUCDISP(STRUC,fileName,'depth',DEPTH,'printValues',PRINTVALUES,. . .
*            'maxArrayLength',MAXARRAYLENGTH) stores
*         the hierarchical outline of a structure and its substructures into
*         the specified file
* 
*  Input:
*    regular:
*        SInp: struct[1,1] - is a structure datatype with unknown field
*            content. It can be  either a scalar or a vector, but not a
*            matrix. STRUC is the only mandatory argument in this function.
*            All other arguments are optional.
* 
*    optional
*        fileName: char[1,] is the name of the file to which the output
*            should be printed. if this argument is not defined, the output
*            is printed to the command window.
* 
*    properties
*        depth: numeric[1,1] - the number of hierarchical levels of
*            the structure that are printed. If DEPTH is smaller than zero,
*            all levels are printed. Default value for DEPTH is -1
*            (print all levels).
* 
*        printValues: logical[1,1] -  flag that states if the field values
*            should be printed  as well. The default value is 1 (print values)
* 
*        maxArrayLength: numberic[1,1] - a positive integer,
*            which determines up to which length or size the values of
*            a vector or matrix are printed. For a  vector holds that
*            if the length of the vector is smaller or equal to
*            MAXARRAYLENGTH, the values are printed. If the vector is
*            longer than MAXARRAYLENGTH, then only the size of the
*            vector is printed. The values of a 2-dimensional (m,n)
*            array are printed if the number of elements (m x n) is
*            smaller or equal to MAXARRAYLENGTH. For vectors and arrays,
*            this constraint overrides the PRINTVALUES flag.
*        numberFormat: char[1,] - format specification used for displaying
*            numberic values, passed directly to sprintf, by default '%g' is
*            used
*  Output:
*    regular:
*        resStr: char [1,] - resulting string with displayed
*            structure contents
* 
Author
Peter Gagarinov, PhD pgaga.nosp@m.rino.nosp@m.v@gma.nosp@m.il.c.nosp@m.om

◆ struct2str()

function mxberry::core::struct::struct2str ( in  SInp,
in  varargin 
)

STRUCDISP display structure outline.

*  Usage: STRUCT2STR(STRUC,fileName,'depth',DEPTH,'printValues',PRINTVALUES,. . .
*            'maxArrayLength',MAXARRAYLENGTH) stores
*         the hierarchical outline of a structure and its substructures into
*         the specified file
* 
*  Input:
*    regular:
*        SInp: struct[1,1] - is a structure datatype with unknown field
*            content. It can be  either a scalar or a vector, but not a
*            matrix. STRUC is the only mandatory argument in this function.
*            All other arguments are optional.
* 
*    optional
*        fileName: char[1,] is the name of the file to which the output
*            should be printed. if this argument is not defined, the output
*            is printed to the command window.
* 
*    properties
*        depth: numeric[1,1] - the number of hierarchical levels of
*            the structure that are printed. If DEPTH is smaller than zero,
*            all levels are printed. Default value for DEPTH is -1
*            (print all levels).
* 
*        printValues: logical[1,1] -  flag that states if the field values
*            should be printed  as well. The default value is 1 (print values)
* 
*        maxArrayLength: numeric[1,1] - a positive integer,
*            which determines up to which length or size the values of
*            a vector or matrix are printed. For a  vector holds that
*            if the length of the vector is smaller or equal to
*            MAXARRAYLENGTH, the values are printed. If the vector is
*            longer than MAXARRAYLENGTH, then only the size of the
*            vector is printed. The values of a 2-dimensional (m,n)
*            array are printed if the number of elements (m x n) is
*            smaller or equal to MAXARRAYLENGTH. For vectors and arrays,
*            this constraint overrides the PRINTVALUES flag.
*        numberFormat: char[1,] - format specification used for displaying
*            numberic values, passed directly to sprintf, by default '%g' is
*            used
* 
Author
Peter Gagarinov, PhD pgaga.nosp@m.rino.nosp@m.v@gma.nosp@m.il.c.nosp@m.om

◆ structapplypath()

function mxberry::core::struct::structapplypath ( in  structB,
in  path,
in  value 
)

STRUCTAPPLYPATH for given a path '.a.b.c.d.' and a value and a structB, returns modified structB, so that structB.a.b.c.d==value;.

*  Usage: structB=structapplypath(structB,path,value)
* 
*  input:
*    regular:
*        structB - a struct
*        path: string, 'a.b.c.d', in this case 'a' is ignored, and the value
*            is stored in structB.b.c.d, the correct path begins from dot.
*        value: value to be stored
* 
*  output:
*    regular:
*        structB - a struct
* 
Author
Peter Gagarinov, PhD pgaga.nosp@m.rino.nosp@m.v@gma.nosp@m.il.c.nosp@m.om

◆ structcheckpath()

function mxberry::core::struct::structcheckpath ( in  SInpArr,
in  pathStr 
)

STRUCTCHECKPATH for a given path ('a.b.c.d.' or {'a','b','c','d'} and a structure array SInpArr returns true, if this path exists for all structure array elements on any nesting level.

*  Usage: isPos=structcheckpath(SInpArr,pathStr)
* 
*  Input:
*    regular:
*        SInpArr: struct[] - input structure array of arbitrary size
*        pathStr: char[1,]/cell[1,] of char[1,] - path to check
* 
*  Output:
*    isPos: logical[1,1] - true if the path SInp exists in the structure
*        pathStr
* 
Author
Peter Gagarinov, PhD pgaga.nosp@m.rino.nosp@m.v@gma.nosp@m.il.c.nosp@m.om

◆ structcompare()

function mxberry::core::struct::structcompare ( in  SX,
in  SY,
in  absTol,
in  relTol 
)

STRUCTCOMPARE compares two structures using the specified tolerance.

*  Input:
*    regular:
*        S1: struct[] - first input structure
*        S2: struct[] - second input structure
*    optional:
*        absTol: double[1,1] - maximum allowed tolerance, default value is 0
*        relTol: double[1,1] - maximum allowed relative tolerance, isn't
*                              used by default
* 
* 
*  Output:
*    isEqual: logical[1,1] - true if the structures are found equal
*    reportStr: char[1,1] report about the found differences
* 
Author
Peter Gagarinov, PhD pgaga.nosp@m.rino.nosp@m.v@gma.nosp@m.il.c.nosp@m.om

◆ structcompare1darray()

function mxberry::core::struct::structcompare1darray ( in  SX,
in  SY,
in  absTol,
in  relTol 
)

STRUCTCOMPARE1D compares 1-dimentional structural arrays.

◆ structcomparescalar()

function mxberry::core::struct::structcomparescalar ( in  SX,
in  SY,
in  absTol,
in  relTol 
)

STRUCTCOMPARE1D compares the scalar structures.

◆ structcomparevec()

function mxberry::core::struct::structcomparevec ( in  SX,
in  SY,
in  absTol,
in  relTol 
)

STRUCTCOMPARE compares two structures using the specified tolerance.

*  Input:
*    regular:
*        SLeft: struct[] - first input structure array
*        SRight: struct[] - second input structure array
*    optional:
*        absTol: double[1,1] - maximum allowed tolerance, default value is 0
*        relTol: double[1,1] - maximum allowed relative tolerance, isn't
*                              used by default
* 
*  Output:
*    isEqualVec: logical[1,] - true if the structures are found equal
*    reportStr: char[1,] report about the found differences
* 
Author
Peter Gagarinov, PhD pgaga.nosp@m.rino.nosp@m.v@gma.nosp@m.il.c.nosp@m.om,
Vadim Kaushansky, PhD vkaus.nosp@m.hans.nosp@m.kiy@g.nosp@m.mail.nosp@m..com

◆ structgetpath()

function mxberry::core::struct::structgetpath ( in  SInpArr,
in  pathStr,
in  isPresenceChecked,
in  isJustCheck 
)

STRUCTGETPATH extract a value from a given structure array using a path specified either as a string or as a sequence of field names separated by dots. It is assumed that all values located at the specified path are of the same size.

*  Usage:
*    SRes=structgetpath(SInpArr,pathStr)
*    SRes=structgetpath(SInpArr,pathStr,false)
* 
*  Input:
*    regular:
*        SInpArr: struct[] - input struct array
*        pathStr: char[1,]/cell[1,] of char[1,] - path in the SInp
*        isPresenceChecked: logical[1,1] - if true, the function doesn't
*            throw an exception if the path is not found and returns
*            isThere=false instead.
*                Default value is FALSE.
*        isJustCheck: logical[1,1] - if true, no value is extracted, just a
*            presence of the specified path is checked. When
*            isJustCheck=true isPresenceChecked is automatically set to true
*                Default value is FALSE.
* 
*    Note: when isJustCheck=true the function is more prohibitive as it
*        doesn't check for consistency of sizes for values of different
*        structure array elements. However, when isJustCheck=false the
*        function attempts to extract values concatenating them via cell2mat
*        function. This may result into either a failure
*        (isPresenceChecked=false) or isThere=false when
*        (isPresenceChecked=true) even if with isJustCheck=true the function
*        returned isThere=true.
* 
*  Output:
*    SRes: struct[] - struct array of the same size as SInpArr
*    isThere: logical[1,1] - if false, the specified path is not found in
*        SInpArr
* 
Author
Peter Gagarinov, PhD pgaga.nosp@m.rino.nosp@m.v@gma.nosp@m.il.c.nosp@m.om

◆ toNumericSupportingMinus()

function mxberry::core::struct::toNumericSupportingMinus ( in  x)

◆ unionstructsalongdim()

function mxberry::core::struct::unionstructsalongdim ( in  catDimension,
in  varargin 
)

UNIONSTRUCTS unites structures with the same fields by concatenating the corresponding fields along the specified dimension.

*  Input:
*    regular:
*        catDimension: numeric[1,1] - dimension number along which the
*           concatenation is to be performed
* 
*    optional:
*        struct1: struct[n1,n2,. . .,n_k]
*        . . .
*        structN: struct[n1,n2,. . .,n_k]
* 
* 
*  Output:
*    SRes: struct[n1,n2,. . .,n_k] - resulting structure
* 
Author
Peter Gagarinov, PhD pgaga.nosp@m.rino.nosp@m.v@gma.nosp@m.il.c.nosp@m.om

◆ updateleaves()

function mxberry::core::struct::updateleaves ( in  SData,
in  fUpdateFunc 
)

UPDATELEAVES applies the specified function to each structure leave value and returns the updated structure.

*  Input:
*    regular:
*        SData: struct[1,1] - input data structure
*        fUpdateFunc: function_handle[1,1] - function with 2 input
*            arguments: field value and field path and 1 output argument -
*            updated field value
* 
*  Output
*    SData: struct[1,1] - updated structure
* 
Author
Peter Gagarinov, PhD pgaga.nosp@m.rino.nosp@m.v@gma.nosp@m.il.c.nosp@m.om

◆ updateleavesext()

function mxberry::core::struct::updateleavesext ( in  SData,
in  fUpdateFunc 
)

UPDATELEAVESEXT applies the specified function to each structure leave value and returns the updated structure, potentially with changed field paths.

*  Input:
*    regular:
*        SData: struct[1,1] - input data structure
*        fUpdateFunc: function_handle[1,1] - function with 2 input
*            arguments: field value and field path and 2 output argument -
*            updated field value and updated field path
* 
*  Output
*    SData: struct[1,1] - updated structure
* 
Author
Peter Gagarinov, PhD pgaga.nosp@m.rino.nosp@m.v@gma.nosp@m.il.c.nosp@m.om

◆ updaterescell()

function mxberry::core::struct::updaterescell ( )