Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
LanczosPlusPlus
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
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
Alvarez, Gonzalo
LanczosPlusPlus
Commits
52bd69e6
Commit
52bd69e6
authored
5 years ago
by
Alvarez, Gonzalo
Browse files
Options
Downloads
Patches
Plain Diff
RahulOperator added
parent
4b0ccacb
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Engine/RahulOperator.h
+64
-0
64 additions, 0 deletions
src/Engine/RahulOperator.h
with
64 additions
and
0 deletions
src/Engine/RahulOperator.h
0 → 100644
+
64
−
0
View file @
52bd69e6
#ifndef RAHULOPERATOR_H
#define RAHULOPERATOR_H
#include
"Vector.h"
namespace
LanczosPlusPlus
{
template
<
typename
ComplexOrRealType
>
class
RahulOperator
{
enum
class
Label
{
IDENTITY
,
N
,
SZ
,
C
};
public
:
RahulOperator
(
PsimagLite
::
String
label
,
SizeType
dof
,
bool
transpose
=
false
)
:
dof_
(
dof
),
transpose_
(
transpose
)
{
label_
=
fromString
(
label
);
}
SizeType
dof
()
const
{
return
dof_
;
}
// The output of this function should be interpreted as follows.
// If the function returns false, bit and result MUST BE ignored
// If the function results true, bit is what the bit should be and result
// contains the multiplier
bool
actOn
(
bool
&
bit
,
ComplexOrRealType
&
result
)
const
{
static
const
ComplexOrRealType
zeroPointFive
=
0.5
;
result
=
1
;
const
bool
bitSaved
=
bit
;
switch
(
label_
)
{
case
Label
::
IDENTITY
:
return
true
;
break
;
case
Label
::
N
:
result
=
(
bitSaved
)
?
0
:
1
;
return
true
;
case
Label
::
SZ
:
result
=
(
bitSaved
)
?
-
zeroPointFive
:
zeroPointFive
;
return
true
;
case
Label
::
C
:
bit
=
!
bit
;
return
((
bitSaved
&&
!
transpose_
)
||
(
!
bitSaved
&&
transpose_
));
default:
throw
PsimagLite
::
RuntimeError
(
"RahulOperator::actOn internal error
\n
"
);
break
;
}
}
private
:
static
Label
fromString
(
PsimagLite
::
String
l
)
{
if
(
l
==
"c"
)
return
Label
::
C
;
if
(
l
==
"identity"
)
return
Label
::
IDENTITY
;
throw
PsimagLite
::
RuntimeError
(
"RahulOperator: Unknow label "
+
l
+
"
\n
"
);
}
SizeType
dof_
;
bool
transpose_
;
Label
label_
;
};
}
#endif // RAHULOPERATOR_H
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