# doc-cache created by Octave 4.0.0
# name: cache
# type: cell
# rows: 3
# columns: 8
# name: <cell-element>
# type: sq_string
# elements: 1
# length: 7
jsonopt


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 713

 val=jsonopt(key,default,optstruct)

 setting options based on a struct. The struct can be produced
 by varargin2struct from a list of 'param','value' pairs

 authors:Qianqian Fang (fangq<at> nmr.mgh.harvard.edu)

 $Id: loadjson.m 371 2012-06-20 12:43:06Z fangq $

 input:
      key: a string with which one look up a value from a struct
      default: if the key does not exist, return default
      optstruct: a struct where each sub-field is a key 

 output:
      val: if key exists, val=optstruct.key; otherwise val=default

 license:
     BSD or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details

 -- this function is part of jsonlab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)
 



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 36

 val=jsonopt(key,default,optstruct)



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 8
loadjson


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 2828

 data=loadjson(fname,opt)
    or
 data=loadjson(fname,'param1',value1,'param2',value2,...)

 parse a JSON (JavaScript Object Notation) file or string

 authors:Qianqian Fang (fangq<at> nmr.mgh.harvard.edu)
 created on 2011/09/09, including previous works from 

         Nedialko Krouchev: http://www.mathworks.com/matlabcentral/fileexchange/25713
            created on 2009/11/02
         François Glineur: http://www.mathworks.com/matlabcentral/fileexchange/23393
            created on  2009/03/22
         Joel Feenstra:
         http://www.mathworks.com/matlabcentral/fileexchange/20565
            created on 2008/07/03

 $Id: loadjson.m 492 2015-06-05 20:52:02Z fangq $

 input:
      fname: input file name, if fname contains "{}" or "[]", fname
             will be interpreted as a JSON string
      opt: a struct to store parsing options, opt can be replaced by 
           a list of ('param',value) pairs - the param string is equivallent
           to a field in opt. opt can have the following 
           fields (first in [.|.] is the default)

           opt.SimplifyCell [0|1]: if set to 1, loadjson will call cell2mat
                         for each element of the JSON data, and group 
                         arrays based on the cell2mat rules.
           opt.FastArrayParser [1|0 or integer]: if set to 1, use a
                         speed-optimized array parser when loading an 
                         array object. The fast array parser may 
                         collapse block arrays into a single large
                         array similar to rules defined in cell2mat; 0 to 
                         use a legacy parser; if set to a larger-than-1
                         value, this option will specify the minimum
                         dimension to enable the fast array parser. For
                         example, if the input is a 3D array, setting
                         FastArrayParser to 1 will return a 3D array;
                         setting to 2 will return a cell array of 2D
                         arrays; setting to 3 will return to a 2D cell
                         array of 1D vectors; setting to 4 will return a
                         3D cell array.
           opt.ShowProgress [0|1]: if set to 1, loadjson displays a progress bar.

 output:
      dat: a cell array, where {...} blocks are converted into cell arrays,
           and [...] are converted to arrays

 examples:
      dat=loadjson('{"obj":{"string":"value","array":[1,2,3]}}')
      dat=loadjson(['examples' filesep 'example1.json'])
      dat=loadjson(['examples' filesep 'example1.json'],'SimplifyCell',1)

 license:
     BSD or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details 

 -- this function is part of JSONLab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)




# name: <cell-element>
# type: sq_string
# elements: 1
# length: 80

 data=loadjson(fname,opt)
    or
 data=loadjson(fname,'param1',value1,'param2',



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 10
loadubjson


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 2102

 data=loadubjson(fname,opt)
    or
 data=loadubjson(fname,'param1',value1,'param2',value2,...)

 parse a JSON (JavaScript Object Notation) file or string

 authors:Qianqian Fang (fangq<at> nmr.mgh.harvard.edu)
 created on 2013/08/01

 $Id: loadubjson.m 492 2015-06-05 20:52:02Z fangq $

 input:
      fname: input file name, if fname contains "{}" or "[]", fname
             will be interpreted as a UBJSON string
      opt: a struct to store parsing options, opt can be replaced by 
           a list of ('param',value) pairs - the param string is equivallent
           to a field in opt. opt can have the following 
           fields (first in [.|.] is the default)

           opt.SimplifyCell [0|1]: if set to 1, loadubjson will call cell2mat
                         for each element of the JSON data, and group 
                         arrays based on the cell2mat rules.
           opt.IntEndian [B|L]: specify the endianness of the integer fields
                         in the UBJSON input data. B - Big-Endian format for 
                         integers (as required in the UBJSON specification); 
                         L - input integer fields are in Little-Endian order.
           opt.NameIsString [0|1]: for UBJSON Specification Draft 8 or 
                         earlier versions (JSONLab 1.0 final or earlier), 
                         the "name" tag is treated as a string. To load 
                         these UBJSON data, you need to manually set this 
                         flag to 1.

 output:
      dat: a cell array, where {...} blocks are converted into cell arrays,
           and [...] are converted to arrays

 examples:
      obj=struct('string','value','array',[1 2 3]);
      ubjdata=saveubjson('obj',obj);
      dat=loadubjson(ubjdata)
      dat=loadubjson(['examples' filesep 'example1.ubj'])
      dat=loadubjson(['examples' filesep 'example1.ubj'],'SimplifyCell',1)

 license:
     BSD or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details 

 -- this function is part of JSONLab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)




# name: <cell-element>
# type: sq_string
# elements: 1
# length: 80

 data=loadubjson(fname,opt)
    or
 data=loadubjson(fname,'param1',value1,'para



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 11
mergestruct


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 471

 s=mergestruct(s1,s2)

 merge two struct objects into one

 authors:Qianqian Fang (fangq<at> nmr.mgh.harvard.edu)
 date: 2012/12/22

 input:
      s1,s2: a struct object, s1 and s2 can not be arrays

 output:
      s: the merged struct object. fields in s1 and s2 will be combined in s.

 license:
     BSD or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details 

 -- this function is part of jsonlab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)




# name: <cell-element>
# type: sq_string
# elements: 1
# length: 22

 s=mergestruct(s1,s2)



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 8
savejson


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 4778

 json=savejson(rootname,obj,filename)
    or
 json=savejson(rootname,obj,opt)
 json=savejson(rootname,obj,'param1',value1,'param2',value2,...)

 convert a MATLAB object (cell, struct or array) into a JSON (JavaScript
 Object Notation) string

 author: Qianqian Fang (fangq<at> nmr.mgh.harvard.edu)
 created on 2011/09/09

 $Id: savejson.m 492 2015-06-05 20:52:02Z fangq $

 input:
      rootname: the name of the root-object, when set to '', the root name
        is ignored, however, when opt.ForceRootName is set to 1 (see below),
        the MATLAB variable name will be used as the root name.
      obj: a MATLAB object (array, cell, cell array, struct, struct array).
      filename: a string for the file name to save the output JSON data.
      opt: a struct for additional options, ignore to use default values.
        opt can have the following fields (first in [.|.] is the default)

        opt.FileName [''|string]: a file name to save the output JSON data
        opt.FloatFormat ['%.10g'|string]: format to show each numeric element
                         of a 1D/2D array;
        opt.ArrayIndent [1|0]: if 1, output explicit data array with
                         precedent indentation; if 0, no indentation
        opt.ArrayToStruct[0|1]: when set to 0, savejson outputs 1D/2D
                         array in JSON array format; if sets to 1, an
                         array will be shown as a struct with fields
                         "_ArrayType_", "_ArraySize_" and "_ArrayData_"; for
                         sparse arrays, the non-zero elements will be
                         saved to _ArrayData_ field in triplet-format i.e.
                         (ix,iy,val) and "_ArrayIsSparse_" will be added
                         with a value of 1; for a complex array, the 
                         _ArrayData_ array will include two columns 
                         (4 for sparse) to record the real and imaginary 
                         parts, and also "_ArrayIsComplex_":1 is added. 
        opt.ParseLogical [0|1]: if this is set to 1, logical array elem
                         will use true/false rather than 1/0.
        opt.NoRowBracket [1|0]: if this is set to 1, arrays with a single
                         numerical element will be shown without a square
                         bracket, unless it is the root object; if 0, square
                         brackets are forced for any numerical arrays.
        opt.ForceRootName [0|1]: when set to 1 and rootname is empty, savejson
                         will use the name of the passed obj variable as the 
                         root object name; if obj is an expression and 
                         does not have a name, 'root' will be used; if this 
                         is set to 0 and rootname is empty, the root level 
                         will be merged down to the lower level.
        opt.Inf ['"$1_Inf_"'|string]: a customized regular expression pattern
                         to represent +/-Inf. The matched pattern is '([-+]*)Inf'
                         and $1 represents the sign. For those who want to use
                         1e999 to represent Inf, they can set opt.Inf to '$11e999'
        opt.NaN ['"_NaN_"'|string]: a customized regular expression pattern
                         to represent NaN
        opt.JSONP [''|string]: to generate a JSONP output (JSON with padding),
                         for example, if opt.JSONP='foo', the JSON data is
                         wrapped inside a function call as 'foo(...);'
        opt.UnpackHex [1|0]: conver the 0x[hex code] output by loadjson 
                         back to the string form
        opt.SaveBinary [0|1]: 1 - save the JSON file in binary mode; 0 - text mode.
        opt.Compact [0|1]: 1- out compact JSON format (remove all newlines and tabs)

        opt can be replaced by a list of ('param',value) pairs. The param 
        string is equivallent to a field in opt and is case sensitive.
 output:
      json: a string in the JSON format (see http://json.org)

 examples:
      jsonmesh=struct('MeshNode',[0 0 0;1 0 0;0 1 0;1 1 0;0 0 1;1 0 1;0 1 1;1 1 1],... 
               'MeshTetra',[1 2 4 8;1 3 4 8;1 2 6 8;1 5 6 8;1 5 7 8;1 3 7 8],...
               'MeshTri',[1 2 4;1 2 6;1 3 4;1 3 7;1 5 6;1 5 7;...
                          2 8 4;2 8 6;3 8 4;3 8 7;5 8 6;5 8 7],...
               'MeshCreator','FangQ','MeshTitle','T6 Cube',...
               'SpecialData',[nan, inf, -inf]);
      savejson('jmesh',jsonmesh)
      savejson('',jsonmesh,'ArrayIndent',0,'FloatFormat','\t%.5g')

 license:
     BSD or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details

 -- this function is part of JSONLab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)




# name: <cell-element>
# type: sq_string
# elements: 1
# length: 80

 json=savejson(rootname,obj,filename)
    or
 json=savejson(rootname,obj,opt)
 



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 10
saveubjson


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 3928

 json=saveubjson(rootname,obj,filename)
    or
 json=saveubjson(rootname,obj,opt)
 json=saveubjson(rootname,obj,'param1',value1,'param2',value2,...)

 convert a MATLAB object (cell, struct or array) into a Universal 
 Binary JSON (UBJSON) binary string

 author: Qianqian Fang (fangq<at> nmr.mgh.harvard.edu)
 created on 2013/08/17

 $Id: saveubjson.m 492 2015-06-05 20:52:02Z fangq $

 input:
      rootname: the name of the root-object, when set to '', the root name
        is ignored, however, when opt.ForceRootName is set to 1 (see below),
        the MATLAB variable name will be used as the root name.
      obj: a MATLAB object (array, cell, cell array, struct, struct array)
      filename: a string for the file name to save the output UBJSON data
      opt: a struct for additional options, ignore to use default values.
        opt can have the following fields (first in [.|.] is the default)

        opt.FileName [''|string]: a file name to save the output JSON data
        opt.ArrayToStruct[0|1]: when set to 0, saveubjson outputs 1D/2D
                         array in JSON array format; if sets to 1, an
                         array will be shown as a struct with fields
                         "_ArrayType_", "_ArraySize_" and "_ArrayData_"; for
                         sparse arrays, the non-zero elements will be
                         saved to _ArrayData_ field in triplet-format i.e.
                         (ix,iy,val) and "_ArrayIsSparse_" will be added
                         with a value of 1; for a complex array, the 
                         _ArrayData_ array will include two columns 
                         (4 for sparse) to record the real and imaginary 
                         parts, and also "_ArrayIsComplex_":1 is added. 
        opt.ParseLogical [1|0]: if this is set to 1, logical array elem
                         will use true/false rather than 1/0.
        opt.NoRowBracket [1|0]: if this is set to 1, arrays with a single
                         numerical element will be shown without a square
                         bracket, unless it is the root object; if 0, square
                         brackets are forced for any numerical arrays.
        opt.ForceRootName [0|1]: when set to 1 and rootname is empty, saveubjson
                         will use the name of the passed obj variable as the 
                         root object name; if obj is an expression and 
                         does not have a name, 'root' will be used; if this 
                         is set to 0 and rootname is empty, the root level 
                         will be merged down to the lower level.
        opt.JSONP [''|string]: to generate a JSONP output (JSON with padding),
                         for example, if opt.JSON='foo', the JSON data is
                         wrapped inside a function call as 'foo(...);'
        opt.UnpackHex [1|0]: conver the 0x[hex code] output by loadjson 
                         back to the string form

        opt can be replaced by a list of ('param',value) pairs. The param 
        string is equivallent to a field in opt and is case sensitive.
 output:
      json: a binary string in the UBJSON format (see http://ubjson.org)

 examples:
      jsonmesh=struct('MeshNode',[0 0 0;1 0 0;0 1 0;1 1 0;0 0 1;1 0 1;0 1 1;1 1 1],... 
               'MeshTetra',[1 2 4 8;1 3 4 8;1 2 6 8;1 5 6 8;1 5 7 8;1 3 7 8],...
               'MeshTri',[1 2 4;1 2 6;1 3 4;1 3 7;1 5 6;1 5 7;...
                          2 8 4;2 8 6;3 8 4;3 8 7;5 8 6;5 8 7],...
               'MeshCreator','FangQ','MeshTitle','T6 Cube',...
               'SpecialData',[nan, inf, -inf]);
      saveubjson('jsonmesh',jsonmesh)
      saveubjson('jsonmesh',jsonmesh,'meshdata.ubj')

 license:
     BSD or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details

 -- this function is part of JSONLab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)




# name: <cell-element>
# type: sq_string
# elements: 1
# length: 80

 json=saveubjson(rootname,obj,filename)
    or
 json=saveubjson(rootname,obj,op



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 12
struct2jdata


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1283

 newdata=struct2jdata(data,opt,...)

 convert a JData object (in the form of a struct array) into an array

 authors:Qianqian Fang (fangq<at> nmr.mgh.harvard.edu)

 input:
      data: a struct array. If data contains JData keywords in the first
            level children, these fields are parsed and regrouped into a
            data object (arrays, trees, graphs etc) based on JData 
            specification. The JData keywords are
               "_ArrayType_", "_ArraySize_", "_ArrayData_"
               "_ArrayIsSparse_", "_ArrayIsComplex_"
      opt: (optional) a list of 'Param',value pairs for additional options 
           The supported options include
               'Recursive', if set to 1, will apply the conversion to 
                            every child; 0 to disable

 output:
      newdata: the covnerted data if the input data does contain a JData 
               structure; otherwise, the same as the input.

 examples:
      obj=struct('_ArrayType_','double','_ArraySize_',[2 3],
                 '_ArrayIsSparse_',1 ,'_ArrayData_',null);
      ubjdata=struct2jdata(obj);

 license:
     BSD or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details 

 -- this function is part of JSONLab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)




# name: <cell-element>
# type: sq_string
# elements: 1
# length: 36

 newdata=struct2jdata(data,opt,...)



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 15
varargin2struct


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 680

 opt=varargin2struct('param1',value1,'param2',value2,...)
   or
 opt=varargin2struct(...,optstruct,...)

 convert a series of input parameters into a structure

 authors:Qianqian Fang (fangq<at> nmr.mgh.harvard.edu)
 date: 2012/12/22

 input:
      'param', value: the input parameters should be pairs of a string and a value
       optstruct: if a parameter is a struct, the fields will be merged to the output struct

 output:
      opt: a struct where opt.param1=value1, opt.param2=value2 ...

 license:
     BSD or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details 

 -- this function is part of jsonlab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)




# name: <cell-element>
# type: sq_string
# elements: 1
# length: 80

 opt=varargin2struct('param1',value1,'param2',value2,...)
   or
 opt=varargin2s





