-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #444 from astro-informatics/cg_gradient_helper
Add gradient helper for stochastic algorithm
- Loading branch information
Showing
2 changed files
with
35 additions
and
1 deletion.
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
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,34 @@ | ||
#ifndef SOPT_GRADIENT_UTILS_H | ||
#define SOPT_GRADIENT_UTILS_H | ||
|
||
#include "sopt/types.h" | ||
#include "sopt/linear_transform.h" | ||
#include <memory> | ||
|
||
namespace sopt { | ||
|
||
//! A helper object that can hold the measurement operator | ||
//! and the target vector for a given iteration state | ||
template <typename T> | ||
class IterationState { | ||
public: | ||
IterationState() = delete; | ||
|
||
IterationState(const T& target, | ||
std::shared_ptr<sopt::LinearTransform<T>> phi) | ||
: _target(target) { | ||
_phi = phi; | ||
} | ||
|
||
const T& target() const { return _target; } | ||
|
||
const sopt::LinearTransform<T>& phi() const { return *_phi; } | ||
|
||
private: | ||
const T _target; | ||
|
||
std::shared_ptr<sopt::LinearTransform<T>> _phi; | ||
}; | ||
|
||
} // namespace sopt | ||
#endif |