Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
toolbox
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Insights
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
7
Issues
7
List
Boards
Labels
Milestones
Merge Requests
3
Merge Requests
3
Security & Compliance
Security & Compliance
Dependency List
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Institute of Technical Acoustics (ITA)
toolbox
Commits
0e753a93
Commit
0e753a93
authored
Dec 12, 2016
by
Marco Berzborn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
speed improvements for itaValue
parent
ec28dbd8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
29 deletions
+20
-29
kernel/ClassStuff/@itaValue/itaValue.m
kernel/ClassStuff/@itaValue/itaValue.m
+12
-20
kernel/MetaInfo/ita_deal_units.m
kernel/MetaInfo/ita_deal_units.m
+8
-9
No files found.
kernel/ClassStuff/@itaValue/itaValue.m
View file @
0e753a93
...
@@ -39,8 +39,8 @@ classdef itaValue
...
@@ -39,8 +39,8 @@ classdef itaValue
elseif
ischar
(
varargin
{
1
})
elseif
ischar
(
varargin
{
1
})
token
=
varargin
{
1
}(:)
.'
;
token
=
varargin
{
1
}(:)
.'
;
if
~
is
empty
(
str2num
(
token
))
%pre check if only a value inside, pdi
if
~
is
nan
(
str2double
(
token
))
%pre check if only a value inside, pdi
A
.
value
=
str2
num
(
token
);
A
.
value
=
str2
double
(
token
);
else
else
%token_new = token; token_new(token_new == '.') = ' ';
%token_new = token; token_new(token_new == '.') = ' ';
unit_start
=
find
(
isstrprop
(
token
,
'alpha'
));
unit_start
=
find
(
isstrprop
(
token
,
'alpha'
));
...
@@ -59,10 +59,12 @@ classdef itaValue
...
@@ -59,10 +59,12 @@ classdef itaValue
else
else
unit_start
=
unit_start
(
1
);
unit_start
=
unit_start
(
1
);
end
end
catch
% do nothing
end
end
value_token
=
token
(
1
:
unit_start
-
1
);
value_token
=
token
(
1
:
unit_start
-
1
);
value_token
=
value_token
(
value_token
~=
' '
);
value_token
=
value_token
(
value_token
~=
' '
);
A
.
value
=
s
tr2num
(
value_token
);
%#ok<ST2NM>
A
.
value
=
s
scanf
(
value_token
,
'%f'
);
if
isempty
(
A
.
value
)
if
isempty
(
A
.
value
)
A
.
value
=
1
;
A
.
value
=
1
;
end
end
...
@@ -95,7 +97,7 @@ classdef itaValue
...
@@ -95,7 +97,7 @@ classdef itaValue
if
length
(
a
)
>
1
if
length
(
a
)
>
1
res
=
[];
res
=
[];
for
idx
=
1
:
length
(
a
)
for
idx
=
1
:
length
(
a
)
res
=
[
res
' '
num2str
(
a
(
idx
),
varargin
{:})];
res
=
[
res
' '
num2str
(
a
(
idx
),
varargin
{:})];
%#ok<AGROW>
end
end
else
else
res
=
num2str
(
a
.
value
(:),
varargin
{:});
res
=
num2str
(
a
.
value
(:),
varargin
{:});
...
@@ -145,7 +147,7 @@ classdef itaValue
...
@@ -145,7 +147,7 @@ classdef itaValue
% invert a matrix
% invert a matrix
res
=
ita_unit_inv
(
a
);
res
=
ita_unit_inv
(
a
);
values
=
inv
(
double
(
a
));
values
=
inv
(
double
(
a
));
for
idx
=
1
:
size
(
a
,
1
)
;
for
idx
=
1
:
size
(
a
,
1
)
for
jdx
=
1
:
size
(
a
,
2
)
for
jdx
=
1
:
size
(
a
,
2
)
res
(
idx
,
jdx
)
.
value
=
values
(
idx
,
jdx
);
res
(
idx
,
jdx
)
.
value
=
values
(
idx
,
jdx
);
end
end
...
@@ -189,23 +191,13 @@ classdef itaValue
...
@@ -189,23 +191,13 @@ classdef itaValue
%% disp
%% disp
function
disp
(
a
)
function
disp
(
a
)
% show the variable value and string
% spacing = 10;
% for idx = 1:size(a,1)
% aux = '';
% for jdx = 1:size(a,2)
% newString = num2str(a(idx,jdx));
% aux = [newString repmat('',1,spacing - length(newString))];
% end
% disp(aux)
% end
disp
(
num2str
(
a
))
disp
(
num2str
(
a
))
end
end
function
display
(
a
)
function
display
(
a
)
%#ok<DISPLAY>
% show the variable value and string
% show the variable value and string
x
=
ver
(
'matlab'
);
x
=
ver
(
'matlab'
);
if
isempty
(
javachk
(
'desktop'
))
&&
s
tr2num
(
x
.
Version
)
<
7.13
% check if we are in desktop mode
if
isempty
(
javachk
(
'desktop'
))
&&
s
scanf
(
x
.
Version
,
'%f'
)
<
7.13
% check if we are in desktop mode
spacing
=
15
;
spacing
=
15
;
if
size
(
a
,
1
)
==
1
&&
size
(
a
,
2
)
==
1
%normal 1D disp
if
size
(
a
,
1
)
==
1
&&
size
(
a
,
2
)
==
1
%normal 1D disp
...
@@ -286,13 +278,13 @@ classdef itaValue
...
@@ -286,13 +278,13 @@ classdef itaValue
end
end
varargout
{
1
}
=
res
;
%return string for e.g. legend
varargout
{
1
}
=
res
;
%return string for e.g. legend
if
nargout
>=
2
;
if
nargout
>=
2
varargout
{
2
}
=
val
;
%return double for division
varargout
{
2
}
=
val
;
%return double for division
end
end
if
nargout
>=
3
;
if
nargout
>=
3
varargout
{
3
}
=
log_prefix
;
%scaling factor for log10
varargout
{
3
}
=
log_prefix
;
%scaling factor for log10
end
end
end
end
end
end
end
end
\ No newline at end of file
kernel/MetaInfo/ita_deal_units.m
View file @
0e753a93
...
@@ -158,8 +158,8 @@ end
...
@@ -158,8 +158,8 @@ end
end
end
end
end
[
num1
den1
]
=
unitstr2nums
(
numToken
);
[
num1
,
den1
]
=
unitstr2nums
(
numToken
);
[
den2
num2
]
=
unitstr2nums
(
denToken
);
[
den2
,
num2
]
=
unitstr2nums
(
denToken
);
num
=
num1
*
num2
;
num
=
num1
*
num2
;
den
=
den1
*
den2
;
den
=
den1
*
den2
;
...
@@ -169,7 +169,7 @@ end
...
@@ -169,7 +169,7 @@ end
return
;
return
;
end
end
unitStr
(
unitStr
==
'*'
)
=
' '
;
unitStr
(
unitStr
==
'*'
)
=
' '
;
tokenPos
=
findstr
(
unitStr
,
' '
);
tokenPos
=
strfind
(
unitStr
,
' '
);
tokenPos
=
[
1
tokenPos
length
(
unitStr
)];
tokenPos
=
[
1
tokenPos
length
(
unitStr
)];
num
=
1
;
den
=
1
;
%init
num
=
1
;
den
=
1
;
%init
...
@@ -192,7 +192,7 @@ end
...
@@ -192,7 +192,7 @@ end
end
end
exponent
=
1
;
exponent
=
1
;
if
any
(
isstrprop
(
token
,
'digit'
))
if
any
(
isstrprop
(
token
,
'digit'
))
exponent
=
s
tr2num
(
token
(
isstrprop
(
token
,
'digit'
))
);
exponent
=
s
scanf
(
token
(
isstrprop
(
token
,
'digit'
)),
'%f'
);
token
=
token
(
~
isstrprop
(
token
,
'digit'
));
token
=
token
(
~
isstrprop
(
token
,
'digit'
));
end
end
...
@@ -253,7 +253,6 @@ end
...
@@ -253,7 +253,6 @@ end
den
=
den
*
cc
.
tesla
(
2
)
.^
exponent
;
den
=
den
*
cc
.
tesla
(
2
)
.^
exponent
;
case
'rad'
case
'rad'
num
=
num
*
cc
.
rad
.^
exponent
;
num
=
num
*
cc
.
rad
.^
exponent
;
den
=
den
;
otherwise
otherwise
if
~
isempty
(
token
)
if
~
isempty
(
token
)
ita_verbose_info
([
'Oh Lord. I do not know this unit: '
token
'! Ignoring this...'
])
ita_verbose_info
([
'Oh Lord. I do not know this unit: '
token
'! Ignoring this...'
])
...
@@ -355,10 +354,10 @@ end
...
@@ -355,10 +354,10 @@ end
end
end
%% more than one element?
%% more than one element?
if
~
isempty
(
findstr
(
numStr
,
' '
)
)
%#ok<*REMFF1> %more than one token
if
~
isempty
(
strfind
(
numStr
,
' '
)
)
%#ok<*REMFF1> %more than one token
numStr
=
[
'('
numStr
')'
];
numStr
=
[
'('
numStr
')'
];
end
end
if
~
isempty
(
findstr
(
denStr
,
' '
)
)
%more than one token
if
~
isempty
(
strfind
(
denStr
,
' '
)
)
%more than one token
denStr
=
[
'('
denStr
')'
];
denStr
=
[
'('
denStr
')'
];
end
end
if
isempty
(
numStr
)
&&
isempty
(
denStr
)
if
isempty
(
numStr
)
&&
isempty
(
denStr
)
...
@@ -694,7 +693,7 @@ end
...
@@ -694,7 +693,7 @@ end
for
i
=
maxExponent
:
-
1
:
1
for
i
=
maxExponent
:
-
1
:
1
if
isfactor
(
numFactor
.^
i
,
iNum
)
&&
isfactor
(
denFactor
.^
i
,
iDen
)
if
isfactor
(
numFactor
.^
i
,
iNum
)
&&
isfactor
(
denFactor
.^
i
,
iDen
)
if
i
~=
1
if
i
~=
1
newString
=
[
newString
'^'
num2str
(
i
)];
%#ok<AGROW>
newString
=
[
newString
'^'
num2str
(
i
)];
end
end
iNum
=
iNum
/
numFactor
.^
i
;
iNum
=
iNum
/
numFactor
.^
i
;
iDen
=
iDen
/
denFactor
.^
i
;
iDen
=
iDen
/
denFactor
.^
i
;
...
@@ -831,7 +830,7 @@ end
...
@@ -831,7 +830,7 @@ end
function
[
iNum
,
iDen
,
numString
]
=
check4hertz
(
iNum
,
iDen
,
numString
)
function
[
iNum
,
iDen
,
numString
]
=
check4hertz
(
iNum
,
iDen
,
numString
)
numFactor
=
1
;
denFactor
=
cc
.
second
;
newString
=
'Hz'
;
%hertz
numFactor
=
1
;
denFactor
=
cc
.
second
;
newString
=
'Hz'
;
%hertz
if
iDen
==
denFactor
&&
iNum
==
numFactor
;
if
iDen
==
denFactor
&&
iNum
==
numFactor
iNum
=
iNum
/
numFactor
;
iNum
=
iNum
/
numFactor
;
iDen
=
iDen
/
denFactor
;
iDen
=
iDen
/
denFactor
;
numString
=
appendString
(
numString
,
newString
);
numString
=
appendString
(
numString
,
newString
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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