diff --git a/include/operon/optimizer/likelihood/gaussian_likelihood.hpp b/include/operon/optimizer/likelihood/gaussian_likelihood.hpp index 9d47be50..fd20057c 100644 --- a/include/operon/optimizer/likelihood/gaussian_likelihood.hpp +++ b/include/operon/optimizer/likelihood/gaussian_likelihood.hpp @@ -44,12 +44,13 @@ struct GaussianLikelihood : public LikelihoodBase { , jac_{bs_, np_} { } - using Scalar = LikelihoodBase::Scalar; + using Scalar = typename LikelihoodBase::Scalar; using scalar_t = Scalar; // needed by lbfgs library NOLINT - using Vector = LikelihoodBase::Vector; - using Ref = LikelihoodBase::Ref; - using Cref = LikelihoodBase::Cref; + using Vector = typename LikelihoodBase::Vector; + using Ref = typename LikelihoodBase::Ref; + using Cref = typename LikelihoodBase::Cref; + using Matrix = typename LikelihoodBase::Matrix; // this loss can be used by the SGD or LBFGS optimizers auto operator()(Cref x, Ref g) const noexcept -> Operon::Scalar final { @@ -99,12 +100,11 @@ struct GaussianLikelihood : public LikelihoodBase { return std::numeric_limits::quiet_NaN(); } - static auto ComputeFisherMatrix(Span pred, Span jac, Span sigma) -> LikelihoodBase::Matrix + static auto ComputeFisherMatrix(Span pred, Span jac, Span sigma) -> Matrix { EXPECT(!sigma.empty()); auto const rows = pred.size(); auto const cols = jac.size() / pred.size(); - using Matrix = LikelihoodBase::Matrix; Eigen::Map m(jac.data(), rows, cols); typename LikelihoodBase::Matrix f = m.transpose() * m; if (sigma.size() == 1) { diff --git a/include/operon/optimizer/likelihood/poisson_likelihood.hpp b/include/operon/optimizer/likelihood/poisson_likelihood.hpp index aaab08d8..06a29c12 100644 --- a/include/operon/optimizer/likelihood/poisson_likelihood.hpp +++ b/include/operon/optimizer/likelihood/poisson_likelihood.hpp @@ -44,12 +44,6 @@ namespace detail { template struct PoissonLikelihood : public LikelihoodBase { - using Scalar = T; - using Vector = Eigen::Matrix; - using Ref = Eigen::Ref; - using Cref = Eigen::Ref const&; - - using scalar_t = T; // for lbfgs solver NOLINT PoissonLikelihood(Operon::RandomGenerator& rng, InterpreterBase const& interpreter, Operon::Span target, Operon::Range const range, std::size_t const batchSize = 0) : LikelihoodBase(interpreter) @@ -62,6 +56,14 @@ struct PoissonLikelihood : public LikelihoodBase { , jac_{bs_, np_} { } + using Scalar = typename LikelihoodBase::Scalar; + using scalar_t = Scalar; // needed by lbfgs library NOLINT + + using Vector = typename LikelihoodBase::Vector; + using Ref = typename LikelihoodBase::Ref; + using Cref = typename LikelihoodBase::Cref; + using Matrix = typename LikelihoodBase::Matrix; + // this loss can be used by the SGD or LBFGS optimizers auto operator()(Cref x, Ref g) const noexcept -> Operon::Scalar final { ++feval_; @@ -95,11 +97,10 @@ struct PoissonLikelihood : public LikelihoodBase { return vstat::univariate::accumulate(x.begin(), x.end(), y.begin(), F{}).sum; } - static auto ComputeFisherMatrix(Span pred, Span jac, Span /*not used*/) -> LikelihoodBase::Matrix + static auto ComputeFisherMatrix(Span pred, Span jac, Span /*not used*/) -> Matrix { auto const rows = pred.size(); auto const cols = jac.size() / pred.size(); - using Matrix = LikelihoodBase::Matrix; Eigen::Map m(jac.data(), rows, cols); Eigen::Map s{pred.data(), std::ssize(pred)};