Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
toolbox
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Marco Berzborn
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
elseif
ischar
(
varargin
{
1
})
token
=
varargin
{
1
}(:)
.'
;
if
~
is
empty
(
str2num
(
token
))
%pre check if only a value inside, pdi
A
.
value
=
str2
num
(
token
);
if
~
is
nan
(
str2double
(
token
))
%pre check if only a value inside, pdi
A
.
value
=
str2
double
(
token
);
else
%token_new = token; token_new(token_new == '.') = ' ';
unit_start
=
find
(
isstrprop
(
token
,
'alpha'
));
...
...
@@ -59,10 +59,12 @@ classdef itaValue
else
unit_start
=
unit_start
(
1
);
end
catch
% do nothing
end
value_token
=
token
(
1
:
unit_start
-
1
);
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
)
A
.
value
=
1
;
end
...
...
@@ -95,7 +97,7 @@ classdef itaValue
if
length
(
a
)
>
1
res
=
[];
for
idx
=
1
:
length
(
a
)
res
=
[
res
' '
num2str
(
a
(
idx
),
varargin
{:})];
res
=
[
res
' '
num2str
(
a
(
idx
),
varargin
{:})];
%#ok<AGROW>
end
else
res
=
num2str
(
a
.
value
(:),
varargin
{:});
...
...
@@ -145,7 +147,7 @@ classdef itaValue
% invert a matrix
res
=
ita_unit_inv
(
a
);
values
=
inv
(
double
(
a
));
for
idx
=
1
:
size
(
a
,
1
)
;
for
idx
=
1
:
size
(
a
,
1
)
for
jdx
=
1
:
size
(
a
,
2
)
res
(
idx
,
jdx
)
.
value
=
values
(
idx
,
jdx
);
end
...
...
@@ -189,23 +191,13 @@ classdef itaValue
%% disp
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
))
end
function
display
(
a
)
function
display
(
a
)
%#ok<DISPLAY>
% show the variable value and string
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
;
if
size
(
a
,
1
)
==
1
&&
size
(
a
,
2
)
==
1
%normal 1D disp
...
...
@@ -286,13 +278,13 @@ classdef itaValue
end
varargout
{
1
}
=
res
;
%return string for e.g. legend
if
nargout
>=
2
;
if
nargout
>=
2
varargout
{
2
}
=
val
;
%return double for division
end
if
nargout
>=
3
;
if
nargout
>=
3
varargout
{
3
}
=
log_prefix
;
%scaling factor for log10
end
end
end
end
\ No newline at end of file
end
kernel/MetaInfo/ita_deal_units.m
View file @
0e753a93
...
...
@@ -158,8 +158,8 @@ end
end
end
[
num1
den1
]
=
unitstr2nums
(
numToken
);
[
den2
num2
]
=
unitstr2nums
(
denToken
);
[
num1
,
den1
]
=
unitstr2nums
(
numToken
);
[
den2
,
num2
]
=
unitstr2nums
(
denToken
);
num
=
num1
*
num2
;
den
=
den1
*
den2
;
...
...
@@ -169,7 +169,7 @@ end
return
;
end
unitStr
(
unitStr
==
'*'
)
=
' '
;
tokenPos
=
findstr
(
unitStr
,
' '
);
tokenPos
=
strfind
(
unitStr
,
' '
);
tokenPos
=
[
1
tokenPos
length
(
unitStr
)];
num
=
1
;
den
=
1
;
%init
...
...
@@ -192,7 +192,7 @@ end
end
exponent
=
1
;
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'
));
end
...
...
@@ -253,7 +253,6 @@ end
den
=
den
*
cc
.
tesla
(
2
)
.^
exponent
;
case
'rad'
num
=
num
*
cc
.
rad
.^
exponent
;
den
=
den
;
otherwise
if
~
isempty
(
token
)
ita_verbose_info
([
'Oh Lord. I do not know this unit: '
token
'! Ignoring this...'
])
...
...
@@ -355,10 +354,10 @@ end
end
%% 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
')'
];
end
if
~
isempty
(
findstr
(
denStr
,
' '
)
)
%more than one token
if
~
isempty
(
strfind
(
denStr
,
' '
)
)
%more than one token
denStr
=
[
'('
denStr
')'
];
end
if
isempty
(
numStr
)
&&
isempty
(
denStr
)
...
...
@@ -694,7 +693,7 @@ end
for
i
=
maxExponent
:
-
1
:
1
if
isfactor
(
numFactor
.^
i
,
iNum
)
&&
isfactor
(
denFactor
.^
i
,
iDen
)
if
i
~=
1
newString
=
[
newString
'^'
num2str
(
i
)];
%#ok<AGROW>
newString
=
[
newString
'^'
num2str
(
i
)];
end
iNum
=
iNum
/
numFactor
.^
i
;
iDen
=
iDen
/
denFactor
.^
i
;
...
...
@@ -831,7 +830,7 @@ end
function
[
iNum
,
iDen
,
numString
]
=
check4hertz
(
iNum
,
iDen
,
numString
)
numFactor
=
1
;
denFactor
=
cc
.
second
;
newString
=
'Hz'
;
%hertz
if
iDen
==
denFactor
&&
iNum
==
numFactor
;
if
iDen
==
denFactor
&&
iNum
==
numFactor
iNum
=
iNum
/
numFactor
;
iDen
=
iDen
/
denFactor
;
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