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

Working #783

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
10 changes: 8 additions & 2 deletions source/function/function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -396,8 +396,14 @@ template<class P, class SIG> auto Function<P,SIG>::get(SizeType i) const -> Scal
template<class P, class SIG> Void Function<P,SIG>::set(SizeType i, ScalarFunction<P,ARG> sf) {
ARIADNE_ASSERT(i<this->result_size());
if constexpr (Same<ResultSizeType,SizeType>) {
const VectorOfScalarFunction<P,ARG>& cvf = dynamic_cast<const FunctionWrapper<VectorOfScalarFunction<P,ARG>,P,SIG>&>(this->_ptr.operator*());
VectorOfScalarFunction<P,ARG>& vf = const_cast<VectorOfScalarFunction<P,ARG>&>(cvf);
const VectorOfScalarFunction<P,ARG>* cvf =
dynamic_cast<const FunctionWrapper<VectorOfScalarFunction<P,ARG>,P,SIG>*>(this->_ptr.operator->());
if (cvf==nullptr) {
ARIADNE_THROW(std::runtime_error,
"Function<P,RealVector(ARGS...)>::set(SizeType i, Function<P,RealScalar(ARGS...)>)",
"Cannot assign to component of vector-valued function "<<(*this)<<" as it is not a VectorOfScalarFunction.");
}
auto vf = const_cast<VectorOfScalarFunction<P,ARG>&>(*cvf);
vf[i]=sf;
} else {
ARIADNE_ASSERT((Same<ResultSizeType,SizeType>));
Expand Down
5 changes: 5 additions & 0 deletions source/function/scaled_function_patch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1192,6 +1192,7 @@ template<class M> class VectorScaledFunctionPatchElementReference
, public ProvideConcreteGenericArithmeticOperators<ScaledFunctionPatch<M>, ScalarMultivariateFunction<typename M::Paradigm>>
, public DispatchConcreteGenericAlgebraNumberOperations<ScaledFunctionPatch<M>,NumericType<M>,Number<typename M::Paradigm>>
{
using P=typename M::Paradigm;
typedef M ModelType;
typedef typename M::NumericType NumericType;
typedef typename M::ErrorType ErrorType;
Expand All @@ -1204,6 +1205,10 @@ template<class M> class VectorScaledFunctionPatchElementReference
VectorScaledFunctionPatchElementReference(const VectorScaledFunctionPatchElementReference<M>& x) = default;
Void operator=(const VectorScaledFunctionPatchElementReference<M>& x) { this->_c->set(this->_i,x._c->get(x._i)); }
Void operator=(const ScalarScaledFunctionPatch<M>& x) { this->_c->set(this->_i,x); }
Void operator=(const ScalarMultivariateFunctionPatch<P> x) {
ScalarScaledFunctionPatch<M> sfp=factory(*this->_c).create(x); *this=sfp; }
Void operator=(const ScalarMultivariateFunction<P> x) {
ScalarScaledFunctionPatch<M> sfp=factory(*this->_c).create(x); *this=sfp; }
ScalarScaledFunctionPatch<M> element() const { return this->_c->get(this->_i); }
BoxDomainType const& domain() const { return this->_c->domain(); }
const ModelType& model() const { return this->_c->_models[this->_i]; }
Expand Down
Loading