![]() |
KerMor
0.9
Model order reduction for nonlinear dynamical systems and nonlinear approximation
|
Collection of generally useful functions. More...
Collection of generally useful functions.
saveFigure
and saveAxes
methods from SegMedix.This class is part of the framework
Homepage
http://www.morepas.org/software/index.htmlDocumentation
http://www.morepas.org/software/kermor/index.htmlLicense
KerMor license conditions Static Public Member Functions | |
static function char short = | getHelpShort (char txt) |
Extracts the help short subtext from a given text. More... | |
static function [ double bmin , double bmax ] = | getBoundingBox (double vectors) |
Gets the bounding box for a matrix containing column vectors. More... | |
static function comb = | createCombinations (ranges, varargin) |
Creates the cartesian product of the vectors passed as a matrix containing elements of each vector per row. More... | |
static function struct target = | copyStructFields (struct source,struct target) |
Recursively copies struct fields from one struct to another. More... | |
static function str = | getLatexStr (value, digits) |
static function char str = | implode (char|rowvec data,char glue,char format) |
Implodes the elements of data using glue. More... | |
static function idx = | findVecInMatrix (A, b) |
Finds column vectors inside a matrix. More... | |
static function y = | preparePlainPlot (y) |
Memory-saving plotting for plain result plots. More... | |
static function | saveFigure (fig, filename, ext) |
Opens a matlab save dialog and saves the given figure to the file selected. More... | |
static function | saveAxes (handle ax, varargin) |
Convenience function. Allows to save a custom axes instead of a whole figure which allows to drop any unwanted uiobjects contained on the source figure. More... | |
static function | removeMargin (f) |
Requires the axes and figure units to be the same. More... | |
static function h = | getHash (vec) |
Returns a hash code for the given vector. More... | |
static function [ matrix < double > x , colvec< double > farend ] = | getTube (integer dim,integer num,double length,double spread,integer seed) |
Computes \(n=\)num random vectors inside a tube of length \(l=\)length inside a \(d=\)dim dimensional space. The tube starts at zero and ends at a random point \(x_e\in\R^d\) of length \(l\). The spread \(s=\)spread determines the maximum distance \(ls\) by which the random vectors might be away from the tube center \(\{x\in\R^d~|~ x = \alpha x_e,\alpha\in[0,1]\}\). More... | |
static function [ double ln , colvec < double > v ] = | logNorm (matrix< double > A,matrix< double > G,colvec< double > v0) |
Computes the logarithmic norm of a matrix \(\vA\), optionally using a positive definite symmetric matrix \(\vG\) inducing the matrix norm to use. More... | |
static function S = | sprand (integer n,integer m,double dens,RandStream rs) |
Creates a random sparse matrix with given density (approximately). More... | |
static function | closeAllFigures () |
static function folder = | getDir (caption, initial_path) |
Prompts the user to select a directory. More... | |
static function logical success = | ensureDir (char dir) |
Ensures that a directory exists. More... | |
static function | copyPrefGroup (char from,char to) |
Copies the preferences from one group to another. More... | |
static function
entries = | getLegendFromVector (values, format_string) |
static function res = | test_Tube () |
static function res = | test_createCombinations () |
Tests the createCombinations function. More... | |
static function res = | test_findVec () |
Tests the findVecInMatrix function. More... | |
Recursively copies struct fields from one struct to another.
Effectively implements a struct.clone() method.
source | The source struct. |
target | The target struct. |
Definition at line 159 of file Utils.m.
References copyStructFields().
Referenced by copyStructFields().
|
static |
Creates the cartesian product of the vectors passed as a matrix containing elements of each vector per row.
ranges | Can either be a cell array of vectors or a vector. |
varargin | If the first argument is a vector, an arbitrary number of additional vectors can be passed to build the cartesian product from. |
comb | A matrix containing the combinations, each row corresponds to an input vector's range. |
Definition at line 114 of file Utils.m.
Referenced by demos.Basics5_KernelsAndApprox(), models.motoneuron.experiments.FrequencyLearning(), models.BaseFullModel.off2_genTrainingData(), sampling.WeightedRandomSampler.performSampling(), sampling.GridSampler.performSampling(), test_createCombinations(), models.muscle.functions.MarkertLaw.test_FitToOriginal(), models.muscle.functions.MarkertLaw.test_Linarization(), and approx.algorithms.VKOGA.test_VKOGA2D1D().
Ensures that a directory exists.
If no return argument is wanted, an exception is thrown when creation of a nonexistent directory fails.
dir | The target directory |
success | True if the directory exists or has been created, false otherwise |
Definition at line 700 of file Utils.m.
Referenced by kernels.KernelExpansion.exportToDirectory().
|
static |
Finds column vectors inside a matrix.
For multiple occurences, the first found index is used.
See http://www.mathworks.com/matlabcentral/newsreader/view_thread/174277 and the test function testing.find_vec_in_matrix_speedtest for further information.
(Daniel Wirtz, 2011-04-12) Added support for multi vector search.
(Daniel Wirtz, 2011-04-13) Fixed errors when multiple occurences appear.
A | A \(n\times m\) matrix of \(m\) column vectors |
b | A \(n\times p\) vector, where each column is regarded as one vector to search |
idx | A \(1 \times p\) vector containing the first found positions indices if a vector from b is contained in A, zero otherwise. |
Definition at line 259 of file Utils.m.
References t.
Referenced by fem.geometry.BaseGeometry.getCommonNodesWith(), spacereduction.BaseSpaceReducer.getInitialSpace(), demos.ResponseSurfaceApprox.iterationPlots(), ApproxVisualizer>plotCurrent(), FunVis2D>updateCenterPoints(), fem.geometry.RegularHex8Grid(), test_findVec(), and fem.geometry.BaseGeometry.toCMGUI().
Gets the bounding box for a matrix containing column vectors.
vectors | A \(n\times m\) matrix containing \(m\) column vectors |
bmin | A \(n\times 1\) vector representing the minimum value corner of the bounding box |
bmax | A \(n\times 1\) vector representing the maximum value corner of the bounding box |
Definition at line 96 of file Utils.m.
Referenced by data.ApproxTrainData.ApproxTrainData(), data.MemoryTrajectoryData.getBoundingBox(), FunVis2D>FunVis2D_OpeningFcn(), FunVis2D>rangesFromATD(), error.IterationCompLemmaEstimator.offlineComputations(), and data.FileMatrix.test_FileMatrix().
|
static |
Prompts the user to select a directory.
If no screen is used, a text input prompt will be used to let the user enter the path manually.
caption | The caption for the dialog/prompt |
initial_path | The path to start from (only for UI) |
Definition at line 669 of file Utils.m.
References all().
Referenced by data.ModelData.relocate().
|
static |
Returns a hash code for the given vector.
Currently using the CalcMD5 routine from 3rdparty/calcmd5, which is included in KerMor as 3rd party code. Original source: http://www.mathworks.com/matlabcentral/fileexchange/25921
Definition at line 493 of file Utils.m.
References CalcMD5().
Referenced by data.FileDataCollection.addData(), data.MemoryTrajectoryData.addTrajectory(), data.FileDataCollection.getData(), data.MemoryTrajectoryData.getTrajectory(), and data.FileDataCollection.hasData().
|
static |
Definition at line 194 of file Utils.m.
Referenced by EstimatorAnalyzer.getResultTable().
|
static |
|
static |
Computes \(n=\)num
random vectors inside a tube of length \(l=\)length
inside a \(d=\)dim
dimensional space. The tube starts at zero and ends at a random point \(x_e\in\R^d\) of length \(l\). The spread \(s=\)spread
determines the maximum distance \(ls\) by which the random vectors might be away from the tube center \(\{x\in\R^d~|~ x = \alpha x_e,\alpha\in[0,1]\}\).
dim | The dimension of the tube. |
num | The number of desired random vectors. |
length | The length \(l\) of the tube. Default: 1 |
spread | The spread \(s\) of the tube vectors around the tube core. Default: 0.15 |
seed | The seed to use for the random number generator. Default: cputime*10 |
x | An \(d\times n\) matrix with random vectors from a random tube. |
farend | The vector from the far end away from zero. |
Definition at line 510 of file Utils.m.
References Norm.L2().
Referenced by test_Tube().
Implodes the elements of data using glue.
Either transforms a cell array of strings into one string or implodes a numeric vector using the specified format.
data | A cell array of strings/chars or a numeric vector |
glue | A string that is inserted between any element string representation Default: , |
format | The sprintf format string if data is a vector Default: %2.3e |
str | The concatented string of all data strings glued together with the string glue |
Definition at line 208 of file Utils.m.
Referenced by IClassConfig.addRange(), ModelAnalyzer.compareRedFull(), Java.exportFunctions(), IClassConfig.getAxisLabels(), kernels.config.ParamTimeExpansionConfig.getConfiguredPropertiesString(), general.functions.FuncSum.getFunction(), general.functions.PiecewiseLinear.getFunction(), general.DEIM.getInterpolationPoints(), fem.AFEMConfig.getOptionStr(), models.pcd.PCDSystem1D.plot(), and MonomialIterator.test_MonomialIterator().
|
static |
Computes the logarithmic norm of a matrix \(\vA\), optionally using a positive definite symmetric matrix \(\vG\) inducing the matrix norm to use.
A | The target matrix \(\vA\) |
G | The positive definite, symmetric matrix \(\vG\) inducing the norm and hence matrix norm to use. Defaults to identity matrix (Euclidean/L2 norm) Default: \(\vI_d\) |
v0 | An initial vector for eigs to start with. Default: [] |
ln | The logarithmic norm with respect to the given matrix norm induced by \(\vG\). |
v | The eigenvector of the largest eigenvalue (=log norm) of the symmetric part of \(\vA\). |
Definition at line 551 of file Utils.m.
References KerMor.App(), and t.
Referenced by testing.DEIM.compareDEIM_Full_Jacobian(), testing.LogNorm.compareSimTransDEIMJac_FullJac(), testing.LogNorm.compareSimTransJac_FullJac(), testing.LogNorm.getApproxLogNormsAtPos(), error.DEIMEstimator.getBeta(), and error.DEIMEstimator.offlineComputations().
|
static |
Memory-saving plotting for plain result plots.
y | A result matrix \(y\) with rows corresponding to single dimensions and columns corresponding to time-steps. |
y | If there are more than 1000 dimensions, the subset with distinct (via unique) last values are extracted. If this still results in more than 4000 plots, the first 4000 dimensions are selected. |
Definition at line 297 of file Utils.m.
Referenced by ModelAnalyzer.analyzeError(), models.BaseModel.plot(), and models.BaseModel.plotState().
|
static |
|
static |
Convenience function. Allows to save a custom axes instead of a whole figure which allows to drop any unwanted uiobjects contained on the source figure.
ax | The axes handle to save. |
varargin | Any additional parameters are passed to Utils.saveFigure |
Definition at line 437 of file Utils.m.
References saveFigure().
Referenced by ApproxVisualizer>btnSave_Callback(), and FunVis2D>uipushtool2_ClickedCallback().
|
static |
Opens a matlab save dialog and saves the given figure to the file selected.
Supported formats: eps, jpg, fig
Definition at line 324 of file Utils.m.
References export_fig(), and KerMor.getPrefTag().
Referenced by models.ReducedModel.createImage(), models.mathmod2012.MathMODExperiment.CreatePlots(), models.iciam2011.ICIAMExperiment.CreatePlots(), models.wh10.WH10Experiment.Experiment2(), models.wh10.WH10Experiment.Experiment4(), and saveAxes().
Creates a random sparse matrix with given density (approximately).
Faster than sprand as no exact density is achieved.
n | The number \(n\) of rows |
m | The number \(m\) of columns |
dens | The desired density \(dens*n*m\) |
rs | A RandStream instance Default: mt19937ar(0) |
Definition at line 629 of file Utils.m.
Referenced by demos.Basics2_Parametrized().
|
static |
Tests the createCombinations function.
Definition at line 771 of file Utils.m.
References createCombinations().
|
static |
Tests the findVecInMatrix function.
Definition at line 788 of file Utils.m.
References all(), and findVecInMatrix().
|
static |