Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
pygwinc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
gwinc
pygwinc
Commits
be4a88c5
Commit
be4a88c5
authored
6 years ago
by
Christopher Wipf
Committed by
Lee McCuller
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Speed up quantum calculation with monolithic matrix multiply
parent
e9aabda9
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!32
Update quantum code from matgwinc, and vectorize
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
gwinc/noise/quantum.py
+12
-15
12 additions, 15 deletions
gwinc/noise/quantum.py
with
12 additions
and
15 deletions
gwinc/noise/quantum.py
+
12
−
15
View file @
be4a88c5
...
...
@@ -421,26 +421,23 @@ def getProdTF(lhs, rhs):
raise
Exception
(
'
Matrix size mismatch size(lhs, 2) = %d != %d = size(rhs, 1)
'
%
(
lhs
.
shape
[
1
],
rhs
.
shape
[
0
]))
N
=
lhs
.
shape
[
0
]
M
=
rhs
.
shape
[
1
]
if
len
(
lhs
.
shape
)
==
3
:
lhs
=
np
.
transpose
(
lhs
,
axes
=
(
2
,
0
,
1
))
if
len
(
rhs
.
shape
)
==
3
:
rhs
=
np
.
transpose
(
rhs
,
axes
=
(
2
,
0
,
1
))
# compute product
if
len
(
lhs
.
shape
)
<
3
or
lhs
.
shape
[
2
]
==
1
:
Nfreq
=
rhs
.
shape
[
2
]
rslt
=
zeros
((
N
,
M
,
Nfreq
),
dtype
=
complex
)
for
n
in
range
(
Nfreq
):
rslt
[:,
:,
n
]
=
np
.
dot
(
np
.
squeeze
(
lhs
),
rhs
[:,
:,
n
])
elif
len
(
rhs
.
shape
)
<
3
or
rhs
.
shape
[
2
]
==
1
:
Nfreq
=
lhs
.
shape
[
2
]
rslt
=
zeros
((
N
,
M
,
Nfreq
),
dtype
=
complex
)
for
n
in
range
(
Nfreq
):
rslt
[:,
:,
n
]
=
np
.
dot
(
lhs
[:,
:,
n
],
np
.
squeeze
(
rhs
))
elif
lhs
.
shape
[
2
]
==
rhs
.
shape
[
2
]:
Nfreq
=
lhs
.
shape
[
2
]
rslt
=
zeros
((
N
,
M
,
Nfreq
),
dtype
=
complex
)
for
n
in
range
(
Nfreq
):
rslt
[:,
:,
n
]
=
np
.
dot
(
lhs
[:,
:,
n
],
rhs
[:,
:,
n
])
if
len
(
lhs
.
shape
)
<
3
or
lhs
.
shape
[
0
]
==
1
:
rslt
=
np
.
matmul
(
lhs
,
rhs
)
elif
len
(
rhs
.
shape
)
<
3
or
rhs
.
shape
[
0
]
==
1
:
rslt
=
np
.
matmul
(
lhs
,
rhs
)
elif
lhs
.
shape
[
0
]
==
rhs
.
shape
[
0
]:
rslt
=
np
.
matmul
(
lhs
,
rhs
)
else
:
raise
Exception
(
'
Matrix size mismatch lhs.shape[2] = %d != %d = rhs.shape[2]
'
%
(
lhs
.
shape
[
2
],
rhs
.
shape
[
2
]))
if
len
(
rslt
.
shape
)
==
3
:
rslt
=
np
.
transpose
(
rslt
,
axes
=
(
1
,
2
,
0
))
return
rslt
...
...
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