KerMor
0.9
Model order reduction for nonlinear dynamical systems and nonlinear approximation
|
FileMatrix: File-based matrix which stores sets of columns in separate files. More...
FileMatrix: File-based matrix which stores sets of columns in separate files.
This class features a caching functionality for the last accessed block, so that for subsequent calls to loadBlock with the same number no new hard drive access is necessary. This makes the FileMatrix almost as fast as a normal matrix when one block is used, i.e. the whole matrix fits into one block of the pre-defined size block_size passed at the constructor.
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 conditionsDefinition at line 18 of file FileMatrix.m.
Public Member Functions | |
FileMatrix (matrix< double > var, varargin) | |
Creates a new file matrix. Possible constructors: More... | |
function B = | spawnWithContent (matrix< double > A) |
Creates a new FileMatrix containing the matrix A. The matrix is stored at the at the same location as the current matrix and the same block size is used. More... | |
function [
rowmin , rowmax ] = | getColBoundingBox () |
Computes the bounding box of the matrix with respect to columns. More... | |
function pos = | getBlockPos (nr) |
Returns the column indices of the block "nr" within the full matrix. More... | |
function copy = | copyWithNewBlockSize (block_size) |
function | relocate (new_root) |
Relocates this FileMatrix instance to a new folder. More... | |
function res = | transposedTimes (B) |
Implements the operation A'*B for this matrix A and another FileMatrix B. More... | |
function s = | sum (dim) |
% Overloaded methods More... | |
function value = | power (expo) |
function n = | numel () |
function [
n , m ] = | size (dim) |
Implementation of ABlockedData.size. More... | |
function
varargout = | subsref (key) |
Implements subscripted value retrieval. More... | |
function this = | subsasgn (key, value) |
Implements subscripted assignment. More... | |
function diff = | minus (B) |
function a = | mldivide (R) |
function AB = | mtimes (B) |
Override of ABlockedData.mtimes. More... | |
function AB = | times (B) |
Override of ABlockedData.mtimes. More... | |
function trans = | ctranspose () |
function res = | eq (B) |
function res = | ne (B) |
function | horzcat (varargin) |
function | vertcat (varargin) |
function | delete () |
function n = | getNumBlocks () |
% data.ABlockedData implementations Implementation of ABlockedData.getNumBlocks More... | |
function B = | getBlock (nr) |
Implementation of ABlockedData.getBlock. More... | |
Public Member Functions inherited from data.FileData | |
FileData (data_dir) | |
function | relocate (char new_root) |
Relocates this FileData instance to a different folder. More... | |
function | delete () |
Public Member Functions inherited from data.ABlockedData | |
function [
matrix< double > U , matrix < double > S , matrix< double > V ] = | getSVD (integer k,matrix< double > Vexclude,colvec< integer > targetdims) |
Computes an SVD on this blockwise matrix \(A = USV^T\). More... | |
function prod = | mtimes () |
Need left-sided matrix multiplication if RHS singular vectors V should be returned. More... | |
function A = | toMemoryMatrix () |
Converts this FileMatrix to a full double matrix. More... | |
Static Public Member Functions | |
static function data.FileMatrix fm = | recoverFrom (char directory) |
Tries to recover a FileMatrix from a given directory, containing the old block data files. More... | |
static function bs = | blockSizeOf (arg1,integer arg2) |
Computes the block size in Megabytes for a given matrix of matrix dimensions. More... | |
static function res = | test_FileMatrix () |
static function res = | test_transposeTimes () |
static function res = | test_SVD () |
static function res = | test_SaveLoad () |
static function res = | test_SumPower () |
static function res = | test_ScalarMult () |
static function res = | test_Times_MTimes () |
static function res = | test_2FileMatrix_MTimes () |
% Two FileMatrices No blocks More... | |
static function res = | test_SpeedSVDTransp () |
Test results for 100000x100 matrix: BlockSVD: Computing truncated 50-SVD on 100x1000000 matrix (3 blocks)... Direct time: 2475.53, Transposed time: 756.023, transposed SVD time: 661.171. More... | |
static function | test_PartialSVD () |
Tests the selective SVD/POD block-wise algorithm. More... | |
Static Public Member Functions inherited from data.ABlockedData | |
static function res = | test_BlockSVD_vs_SVD () |
Public Attributes | |
InPlaceTranspose = false | |
Set this flag to true, if only so much space should be required as actually needed when transposing the matrix (i.e. twice the size of the current matrix). More... | |
integer | bCols |
The number of columns for each block. More... | |
integer | nBlocks |
The number of blocks into which this matrix is separated. More... | |
integer | n |
The number of rows. More... | |
integer | m |
The total number of columns. More... | |
MinValue = Inf | |
MaxValue = -Inf | |
Public Attributes inherited from data.FileData | |
char | Host = "" |
The host machine this file data is created on. More... | |
char | DataDirectory = "" |
The root folder where the FileData's files are saved. More... | |
Public Attributes inherited from handle | |
addlistener | |
Creates a listener for the specified event and assigns a callback function to execute when the event occurs. More... | |
notify | |
Broadcast a notice that a specific event is occurring on a specified handle object or array of handle objects. More... | |
delete | |
Handle object destructor method that is called when the object's lifecycle ends. More... | |
disp | |
Handle object disp method which is called by the display method. See the MATLAB disp function. More... | |
display | |
Handle object display method called when MATLAB software interprets an expression returning a handle object that is not terminated by a semicolon. See the MATLAB display function. More... | |
findobj | |
Finds objects matching the specified conditions from the input array of handle objects. More... | |
findprop | |
Returns a meta.property objects associated with the specified property name. More... | |
fields | |
Returns a cell array of string containing the names of public properties. More... | |
fieldnames | |
Returns a cell array of string containing the names of public properties. See the MATLAB fieldnames function. More... | |
isvalid | |
Returns a logical array in which elements are true if the corresponding elements in the input array are valid handles. This method is Sealed so you cannot override it in a handle subclass. More... | |
eq | |
Relational functions example. See details for more information. More... | |
transpose | |
Transposes the elements of the handle object array. More... | |
permute | |
Rearranges the dimensions of the handle object array. See the MATLAB permute function. More... | |
reshape | |
hanges the dimensions of the handle object array to the specified dimensions. See the MATLAB reshape function. More... | |
sort | |
ort the handle objects in any array in ascending or descending order. More... | |
Public Attributes inherited from data.ABlockedData | |
double | MinRelSingularValueSize = 1e-20 |
The minimum relative value of singular values that triggers selection of the compared to the largest one. More... | |
Static Public Attributes | |
static const ::integer | BLOCK_SIZE = 512 |
The default block size to use for new FileMatrix instances. [MB]. More... | |
Protected Member Functions | |
function this = | saveobj () |
Protected Member Functions inherited from data.FileData | |
function file = | getfile (file) |
function this = | saveobj () |
Set saved flag so that the data files do not get deleted on the delete method. More... | |
Static Protected Member Functions | |
static function this = | loadobj (this, initfrom) |
Loads a FileMatrix instance. More... | |
Static Protected Member Functions inherited from data.FileData | |
static function this = | loadobj (this, initfrom) |
Loads a FileData instance. More... | |
Additional Inherited Members | |
Protected Attributes inherited from data.FileData | |
logical | isSaved = false |
This flag indicates that this FileData instance has been stored to disk via the save method somewhere. More... | |
Creates a new file matrix. Possible constructors:
var | If a scalar, the row dimension. If a matrix, the file matrix is initialized using the matrix value. |
varargin | More optional input arguments, see below. FileMatrix ( ..., m,
"Dir", Dir_value ] [, "BlockSize", BlockSize_value ] )
|
Definition at line 189 of file FileMatrix.m.
References KerMor.App(), bCols, IDGenerator.generateID(), isposrealscalar(), m, n, nBlocks, numel(), handle.reshape, size(), subsasgn(), and t.
Referenced by data.ApproxTrainData.computeFrom().
|
static |
Computes the block size in Megabytes for a given matrix of matrix dimensions.
The matrices are assumed to contain double values.
arg1 | Either a double matrix or the row number |
arg2 | The column number Default: [] |
Definition at line 1108 of file FileMatrix.m.
References numel().
function copy = data.FileMatrix.copyWithNewBlockSize | ( | block_size | ) |
Definition at line 325 of file FileMatrix.m.
References data.FileData.DataDirectory, getBlockPos(), k, m, n, and nBlocks.
function trans = data.FileMatrix.ctranspose | ( | ) |
Definition at line 778 of file FileMatrix.m.
References data.FileData.DataDirectory, getBlockPos(), InPlaceTranspose, k, m, n, nBlocks, and t.
function data.FileMatrix.delete | ( | ) |
Definition at line 880 of file FileMatrix.m.
References data.FileData.DataDirectory, k, and nBlocks.
function res = data.FileMatrix.eq | ( | B | ) |
Definition at line 843 of file FileMatrix.m.
Referenced by ne().
|
virtual |
Implementation of ABlockedData.getBlock.
Implements data.ABlockedData.
Definition at line 908 of file FileMatrix.m.
Referenced by transposedTimes().
function pos = data.FileMatrix.getBlockPos | ( | nr | ) |
Returns the column indices of the block "nr" within the full matrix.
Definition at line 314 of file FileMatrix.m.
Referenced by testing.DEIM.computeDEIMErrors(), copyWithNewBlockSize(), ctranspose(), sum(), and transposedTimes().
function [ rowmin , rowmax ] = data.FileMatrix.getColBoundingBox | ( | ) |
Computes the bounding box of the matrix with respect to columns.
Definition at line 298 of file FileMatrix.m.
Referenced by approx.algorithms.ABase.computeApproximation().
|
virtual |
% data.ABlockedData implementations Implementation of ABlockedData.getNumBlocks
Implements data.ABlockedData.
Definition at line 897 of file FileMatrix.m.
function data.FileMatrix.horzcat | ( | varargin | ) |
Definition at line 870 of file FileMatrix.m.
|
staticprotected |
Loads a FileMatrix instance.
Definition at line 999 of file FileMatrix.m.
References bCols, InPlaceTranspose, m, MaxValue, MinValue, and nBlocks.
function diff = data.FileMatrix.minus | ( | B | ) |
Definition at line 556 of file FileMatrix.m.
function a = data.FileMatrix.mldivide | ( | R | ) |
Definition at line 591 of file FileMatrix.m.
function AB = data.FileMatrix.mtimes | ( | B | ) |
Override of ABlockedData.mtimes.
Definition at line 610 of file FileMatrix.m.
References k, data.ABlockedData.mtimes(), size(), and sum().
function res = data.FileMatrix.ne | ( | B | ) |
Definition at line 865 of file FileMatrix.m.
References eq().
function n = data.FileMatrix.numel | ( | ) |
Definition at line 434 of file FileMatrix.m.
References n.
Referenced by blockSizeOf(), and FileMatrix().
function value = data.FileMatrix.power | ( | expo | ) |
Definition at line 416 of file FileMatrix.m.
References data.FileData.DataDirectory, k, m, n, and nBlocks.
|
static |
Tries to recover a FileMatrix from a given directory, containing the old block data files.
directory | The directory to recover from. If not given, KerMor.getDir is used. Default: KerMor.getDir |
fm | The recovered FileMatrix instance. [] if the KerMor.getDir dialog has been aborted. |
Definition at line 1045 of file FileMatrix.m.
References KerMor.getDir(), k, and size().
function data.FileMatrix.relocate | ( | new_root | ) |
Relocates this FileMatrix instance to a new folder.
Note that the FileMatrix takes a directory inside
which it will create a new directory using a certain hash. Thus, upon relocation, the folder that contains
the created folder must be passed.
For example, assume we have DataDirectory=/some/path/matrix_246sg351dg. Then relocate with /some/new/root
leads to the new path /some/new/root/matrix_246sg351dg
at which the blocks of this file matrix are assumed to reside.
new_root | The root folder that contains a FileMatrix self-defined folder used to store the matrix blocks. |
Definition at line 335 of file FileMatrix.m.
References data.FileData.DataDirectory.
Referenced by data.ApproxTrainData.relocate().
|
protected |
Definition at line 922 of file FileMatrix.m.
References data.FileData.DataDirectory.
Implementation of ABlockedData.size.
Implements data.ABlockedData.
Definition at line 439 of file FileMatrix.m.
Referenced by eq(), FileMatrix(), minus(), mtimes(), recoverFrom(), subsref(), test_PartialSVD(), test_SVD(), test_Times_MTimes(), and times().
Creates a new FileMatrix containing the matrix A. The matrix is stored at the at the same location as the current matrix and the same block size is used.
A | The new matrix. |
B | A new data.FileMatrix instance containing B. |
Definition at line 283 of file FileMatrix.m.
References data.FileData.DataDirectory.
Referenced by data.ApproxTrainData.makeUniqueXi().
function this = data.FileMatrix.subsasgn | ( | key, | |
value | |||
) |
Implements subscripted assignment.
Definition at line 509 of file FileMatrix.m.
Referenced by FileMatrix().
function varargout = data.FileMatrix.subsref | ( | key | ) |
function s = data.FileMatrix.sum | ( | dim | ) |
% Overloaded methods
Definition at line 390 of file FileMatrix.m.
References getBlockPos(), k, m, n, and nBlocks.
Referenced by mtimes(), and test_SumPower().
|
static |
% Two FileMatrices No blocks
Definition at line 1327 of file FileMatrix.m.
|
static |
Definition at line 1130 of file FileMatrix.m.
References all(), Utils.getBoundingBox(), k, and t.
|
static |
Tests the selective SVD/POD block-wise algorithm.
Definition at line 1380 of file FileMatrix.m.
|
static |
Definition at line 1206 of file FileMatrix.m.
|
static |
need implementation for >1 nBlock matrices and scalar values
need separate test for each overridden operator
Definition at line 1243 of file FileMatrix.m.
|
static |
Test results for 100000x100 matrix: BlockSVD: Computing truncated 50-SVD on 100x1000000 matrix (3 blocks)... Direct time: 2475.53, Transposed time: 756.023, transposed SVD time: 661.171.
Thus: Auto-transpose for matrices with nBlocks > 1
Definition at line 1351 of file FileMatrix.m.
References t.
|
static |
|
static |
|
static |
|
static |
Definition at line 1174 of file FileMatrix.m.
References t.
function AB = data.FileMatrix.times | ( | B | ) |
Override of ABlockedData.mtimes.
Definition at line 739 of file FileMatrix.m.
References k, data.ABlockedData.mtimes(), and size().
function res = data.FileMatrix.transposedTimes | ( | B | ) |
Implements the operation A'*B for this matrix A and another FileMatrix B.
Definition at line 365 of file FileMatrix.m.
References getBlock(), getBlockPos(), m, nBlocks, and t.
function data.FileMatrix.vertcat | ( | varargin | ) |
Definition at line 875 of file FileMatrix.m.
data.FileMatrix.bCols |
The number of columns for each block.
SetAccess = Private, GetAccess = Public
Definition at line 82 of file FileMatrix.m.
Referenced by data.ApproxTrainData.computeFrom(), FileMatrix(), getBlockPos(), and loadobj().
|
static |
The default block size to use for new FileMatrix instances. [MB].
This is used as default value in KerMor.App.BlockSize, if not set differently (machine dependent)
The block size unit is Megabyte.
Default: 512MB
Definition at line 49 of file FileMatrix.m.
data.FileMatrix.InPlaceTranspose = false |
Set this flag to true, if only so much space should be required as actually needed when transposing the matrix (i.e. twice the size of the current matrix).
If false (default), running ctranspose will create small blocks fitted to the size of the meshed sizes temporarily. This needs 3 times the space instead of 2 but avoids reloading the whole block even if no data is changed where it already exists.
Default: false
Definition at line 66 of file FileMatrix.m.
Referenced by ctranspose(), and loadobj().
data.FileMatrix.m |
The total number of columns.
SetAccess = Private, GetAccess = Public
Definition at line 126 of file FileMatrix.m.
Referenced by testing.DEIM.computeDEIMErrors(), copyWithNewBlockSize(), ctranspose(), FileMatrix(), getBlockPos(), loadobj(), power(), size(), subsasgn(), subsref(), sum(), and transposedTimes().
data.FileMatrix.MaxValue = -Inf |
Definition at line 142 of file FileMatrix.m.
Referenced by loadobj().
data.FileMatrix.MinValue = Inf |
Definition at line 139 of file FileMatrix.m.
Referenced by loadobj().
data.FileMatrix.n |
The number of rows.
SetAccess = Private, GetAccess = Public
Definition at line 113 of file FileMatrix.m.
Referenced by data.ApproxTrainData.computeFrom(), copyWithNewBlockSize(), ctranspose(), FileMatrix(), getColBoundingBox(), getNumBlocks(), numel(), power(), size(), subsref(), and sum().
data.FileMatrix.nBlocks |
The number of blocks into which this matrix is separated.
The number of blocks is computed from the matrix size and the maximum block size in Bytes.
SetAccess = Private, GetAccess = Public
Definition at line 95 of file FileMatrix.m.
Referenced by testing.DEIM.computeDEIMErrors(), data.ApproxTrainData.computeFrom(), copyWithNewBlockSize(), ctranspose(), delete(), FileMatrix(), getColBoundingBox(), getNumBlocks(), loadobj(), power(), subsasgn(), subsref(), sum(), and transposedTimes().