-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
77 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// | ||
// Created by Justin Turney on 2/4/16. | ||
// | ||
|
||
#ifndef AMBIT_COMPOSITE_TENSOR_H | ||
#define AMBIT_COMPOSITE_TENSOR_H | ||
|
||
#include <ambit/common_types.h> | ||
#include <ambit/tensor.h> | ||
#include <ambit/blocked_tensor.h> | ||
|
||
namespace ambit | ||
{ | ||
|
||
template <typename TensorType> | ||
class CompositeTensor | ||
{ | ||
string name_; | ||
vector<TensorType> tensors_; | ||
|
||
public: | ||
|
||
CompositeTensor(const string& name, size_t ntensors = 0) | ||
: name_(name), tensors_(ntensors+1) | ||
{} | ||
|
||
TensorType& operator()(size_t elem) | ||
{ | ||
return tensors_[elem]; | ||
} | ||
|
||
const TensorType& operator()(size_t elem) const | ||
{ | ||
return tensors_[elem]; | ||
} | ||
|
||
CompositeTensor& add(TensorType& newTensor) | ||
{ | ||
tensors_.push_back(newTensor); | ||
return *this; | ||
} | ||
}; | ||
|
||
} | ||
|
||
#endif //AMBIT_COMPOSITE_TENSOR_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
896a5a6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jturney: this looks interesting! So what can you do with composite tensors?
896a5a6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This initial version is nothing more than a "wrapper" to a vector which allows me to do this:
I'm considering making it able to select the appropriate tensor:
Thoughts?