Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add gradient helper for stochastic algorithm #444

Merged
merged 3 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading