Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
faust
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
GitLab upgrade completed. Current version is 17.11.4.
Show more breadcrumbs
faust group
faust
Commits
71857df5
Commit
71857df5
authored
2 years ago
by
hhakim
Browse files
Options
Downloads
Patches
Plain Diff
Update matfaust.lazylinop multiplication by scalar to be less costly.
parent
3cde8cdf
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
wrapper/matlab/+matfaust/+lazylinop/@LazyLinearOp/LazyLinearOp.m
+11
-14
11 additions, 14 deletions
.../matlab/+matfaust/+lazylinop/@LazyLinearOp/LazyLinearOp.m
wrapper/python/pyfaust/lazylinop.py
+4
-4
4 additions, 4 deletions
wrapper/python/pyfaust/lazylinop.py
with
15 additions
and
18 deletions
wrapper/matlab/+matfaust/+lazylinop/@LazyLinearOp/LazyLinearOp.m
+
11
−
14
View file @
71857df5
...
...
@@ -165,7 +165,7 @@ classdef LazyLinearOp < handle % needed to use references on objects
%> @param op: an object compatible with self for this binary operation.
%=============================================================
function
LM
=
mtimes
(
L
,
A
)
import
matfaust
.
lazylinop
.
LazyLinearOp
import
matfaust
.
lazylinop
.
*
if
LazyLinearOp
.
isLazyLinearOp
(
A
)
if
isscalar
(
L
)
LM
=
mtimes
(
A
,
L
);
...
...
@@ -176,24 +176,19 @@ classdef LazyLinearOp < handle % needed to use references on objects
end
end
check_meth
(
L
,
'mtimes'
);
op
_is_scalar
=
all
(
size
(
A
)
==
[
1
,
1
]);
if
~
op
_is_scalar
&&
~
all
(
size
(
L
,
2
)
==
size
(
A
,
1
))
A
_is_scalar
=
all
(
size
(
A
)
==
[
1
,
1
]);
if
~
A
_is_scalar
&&
~
all
(
size
(
L
,
2
)
==
size
(
A
,
1
))
error
(
'Dimensions must agree'
)
end
if
op_is_scalar
new_size
=
size
(
L
);
else
new_size
=
[
size
(
L
,
1
),
size
(
A
,
2
)];
end
function
l
=
mul_index_lambda
(
L
,
A
,
S
)
function
LMI
=
mul_index_lambda
(
L
,
A
,
S
)
% L and A must be LazyLinearOp
import
matfaust
.
lazylinop
.
LazyLinearOp
Sr
.
type
=
'()'
;
Sr
.
subs
=
{
S
.
subs
{
1
},
':'
};
Sc
.
type
=
'()'
;
Sc
.
subs
=
{
':'
,
S
.
subs
{
2
}};
L
.
lambdas
{
L
.
I
}(
Sr
)
*
A
.
lambdas
{
L
.
I
}(
Sc
);
LMI
=
L
.
lambdas
{
L
.
I
}(
Sr
)
*
A
.
lambdas
{
L
.
I
}(
Sc
);
end
if
~
LazyLinearOp
.
isLazyLinearOp
(
A
)
&&
ismatrix
(
A
)
&&
isnumeric
(
A
)
&&
any
(
size
(
A
)
~=
[
1
,
1
])
...
...
@@ -201,17 +196,19 @@ classdef LazyLinearOp < handle % needed to use references on objects
LM
=
L
.
lambdas
{
L
.
MUL
}(
A
);
else
if
isscalar
(
A
)
LM_size
=
size
(
L
);
matmat
=
@
(
M
)
M
*
A
;
LM
=
L
*
LazyLinearOperator
([
L
.
size
(
2
),
L
.
size
(
2
)],
'matmat'
,
matmat
,
'rmatmat'
,
matmat
);
return
;
else
if
~
LazyLinearOp
.
isLazyLinearOp
(
A
)
A
=
LazyLinearOp
.
create_from_op
(
A
);
end
LM_size
=
[
size
(
L
,
1
),
size
(
A
,
2
)]
LM_size
=
[
size
(
L
,
1
),
size
(
A
,
2
)]
;
end
lambdas
=
{
@
(
o
)
L
*
(
A
*
o
),
...
%MUL
@
()
A
.
' * L.'
,
...
% T
@
()
A
' * L'
,
...
% H
@
()
A
.
' * L.'
,
...
% T
@
()
A
' * L'
,
...
% H
@
(
S
)
mul_index_lambda
(
L
,
A
,
S
)
% I
};
LM
=
LazyLinearOp
(
lambdas
,
LM_size
);
...
...
This diff is collapsed.
Click to expand it.
wrapper/python/pyfaust/lazylinop.py
+
4
−
4
View file @
71857df5
...
...
@@ -590,11 +590,11 @@ class LazyLinearOp(LinearOperator):
<b>See also:</b> pyfaust.lazylinop.LazyLinearOp.__matmul__)
"""
self
.
_checkattr
(
'
__mul__
'
)
from
scipy.sparse
import
eye
if
np
.
isscalar
(
other
):
S
=
eye
(
self
.
shape
[
1
],
format
=
'
csr
'
)
*
other
lop
=
LazyLinearOp
.
create_from_op
(
S
)
new_op
=
self
@
lop
Dshape
=
(
self
.
shape
[
1
],
self
.
shape
[
1
])
matmat
=
lambda
M
:
M
*
other
D
=
LazyLinearOperator
(
Dshape
,
matmat
=
matmat
,
rmatmat
=
matmat
)
new_op
=
self
@
D
else
:
new_op
=
self
@
other
return
new_op
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment