Skip to content

Commit

Permalink
Merge pull request #444 from astro-informatics/cg_gradient_helper
Browse files Browse the repository at this point in the history
Add gradient helper for stochastic algorithm
  • Loading branch information
20DM authored Nov 22, 2024
2 parents 749d6b7 + 7186e31 commit 2d7306e
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cpp/sopt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set(headers
imaging_padmm.h logging.h
forward_backward.h imaging_forward_backward.h
non_differentiable_func.h l1_non_diff_function.h real_indicator.h joint_map.h
differentiable_func.h l2_differentiable_func.h
differentiable_func.h l2_differentiable_func.h gradient_utils.h
imaging_primal_dual.h primal_dual.h
maths.h proximal.h relative_variation.h sdmm.h
wavelets.h conjugate_gradient.h l1_proximal.h padmm.h proximal_expression.h
Expand Down
34 changes: 34 additions & 0 deletions cpp/sopt/gradient_utils.h
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

0 comments on commit 2d7306e

Please sign in to comment.