Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
LRT_infinite_dimensional_systems
conI
Commits
5e74db0a
Commit
5e74db0a
authored
Mar 31, 2020
by
Ferdinand Fischer
Browse files
added hash function to quantity.Discrete and misc
parent
f5b9d15b
Changes
4
Hide whitespace changes
Inline
Side-by-side
+misc/getDimensions.m
View file @
5e74db0a
...
...
@@ -5,7 +5,7 @@ arguments
names
cell
;
dim
=
1
;
end
sizes
=
[]
;
sizes
=
0
;
for
k
=
1
:
length
(
names
)
if
isfield
(
optArg
,
names
{
k
})
sizes
(
k
)
=
size
(
optArg
.
(
names
{
k
}),
dim
);
...
...
+misc/hash.m
0 → 100644
View file @
5e74db0a
function
h
=
hash
(
data
)
%HASH compute the hash for some data
% h = hash(DATA) computes the SHA-1 hash for DATA
B
=
getByteStreamFromArray
(
data
);
Engine
=
java
.
security
.
MessageDigest
.
getInstance
(
'SHA-1'
);
Engine
.
update
(
B
);
h
=
reshape
(
dec2hex
(
typecast
(
Engine
.
digest
(),
'uint8'
)),
1
,
[]);
end
+quantity/Discrete.m
View file @
5e74db0a
...
...
@@ -22,7 +22,7 @@ classdef (InferiorClasses = {?quantity.Symbolic}) Discrete ...
end
properties
(
Dependent
)
% Name of the domains that generate the grid.
gridName
{
mustBe
.
unique
};
...
...
@@ -239,6 +239,22 @@ classdef (InferiorClasses = {?quantity.Symbolic}) Discrete ...
end
methods
(
Access
=
public
)
function
h
=
hash
(
obj
)
%HASH create a SHA-1 hash value for this object
% h = hash(obj) will copmute the SHA-1 hash value based on the
% data "valueDiscrete", "domain.name", "domain.grid",
% "obj.name"
% The hash value can be used to get a "short" identifier for
% this object.
% create a huge array of all relevant quantity data
data
=
{[
obj
.
valueDiscrete
],
obj
(
1
)
.
domain
.
name
,
...
obj
(
1
)
.
domain
.
grid
,
obj
(
1
)
.
name
};
h
=
misc
.
hash
(
data
);
end
function
d
=
compositionDomain
(
obj
,
domainName
)
assert
(
isscalar
(
obj
));
...
...
+unittests/+quantity/testDiscrete.m
View file @
5e74db0a
...
...
@@ -13,6 +13,19 @@ testCase.TestData.sym.t = t;
testCase
.
TestData
.
sym
.
sy
=
sy
;
end
function
testHashData
(
testCase
)
spatialDomain
=
quantity
.
Domain
(
"z"
,
linspace
(
0
,
1
,
101
));
L1
=
quantity
.
Symbolic
(
diag
([
2
,
-
3
]),
...
'domain'
,
spatialDomain
,
'name'
,
'Lambda'
);
L2
=
quantity
.
Symbolic
(
diag
([
1
,
-
1
]),
...
'domain'
,
spatialDomain
,
'name'
,
'Lambda'
);
testCase
.
verifyNotEqual
(
L1
.
hash
,
L2
.
hash
);
end
function
testIsdiag
(
tc
)
z
=
quantity
.
Domain
(
"z"
,
linspace
(
0
,
1
,
11
));
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment