Skip to content

Commit

Permalink
MAINT: Add assignment operators for Input and Parameter classes of so…
Browse files Browse the repository at this point in the history
…lvers (#3049)

* add assignment operator for adagrad input

* add assignment operator for cd input

* add assignment operator for sumtypes input

* add assignment operator for lbfgs input

* add assignment operator for crossentropyloss input

* add assignment operator for crossentropyloss parameters

* add assignment operator for logisticloss input

* add assignment operator for logisticloss parameter

* add assignment operator for mseloss parameter

* add assignment operator for mseloss input

* add assignment operator for functiontypes input

* add assignment operator for functiontypes parameter

* add assignment operator for sumoffunctions parameter

* add assignment operator for saga input

* missing return

* fix wrong signature

* fix incorrect type assignment

* remove accidental semicolon
  • Loading branch information
david-cortes-intel authored Jan 23, 2025
1 parent 96370cc commit d43c4ab
Show file tree
Hide file tree
Showing 20 changed files with 162 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ class DAAL_EXPORT Input : public optimization_solver::iterative_solver::Input
typedef optimization_solver::iterative_solver::Input super;
Input();
Input(const Input & other);
Input & operator=(const Input & other);

using super::set;
using super::get;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ class DAAL_EXPORT Input : public optimization_solver::iterative_solver::Input
public:
Input();
Input(const Input & other);
Input & operator=(const Input & other);

using super::set;
using super::get;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ class DAAL_EXPORT Input : public daal::algorithms::Input
public:
Input();
Input(const Input & other);
Input & operator=(const Input & other);

~Input() DAAL_C11_OVERRIDE {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ class DAAL_EXPORT Input : public optimization_solver::iterative_solver::Input
typedef optimization_solver::iterative_solver::Input super;
Input();
Input(const Input & other);
Input & operator=(const Input & other);
using super::set;
using super::get;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,17 @@ struct DAAL_EXPORT Parameter : public sum_of_functions::Parameter
const DAAL_UINT64 resultsToCompute = objective_function::gradient);

/**
* Constructs an Parameter by copying input objects and parameters of another Parameter
* \param[in] other An object to be used as the source to initialize object
* Constructs a Parameter by copying input objects and parameters of another Parameter
* \param[in] other An object to be used as the source object to initialize from
*/
Parameter(const Parameter & other);

/**
* Assigns a Parameter by copying input objects and parameters of another Parameter
* \param[in] other An object to be used as the source object to copy from
*/
Parameter & operator=(const Parameter & other);

/**
* Checks the correctness of the parameter
*
Expand Down Expand Up @@ -130,6 +137,9 @@ class DAAL_EXPORT Input : public sum_of_functions::Input
/** Copy constructor */
Input(const Input & other);

/** Assignment operator */
Input & operator=(const Input & other);

/** Destructor */
virtual ~Input() {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,17 @@ struct DAAL_EXPORT Parameter : public sum_of_functions::Parameter
const DAAL_UINT64 resultsToCompute = objective_function::gradient);

/**
* Constructs an Parameter by copying input objects and parameters of another Parameter
* \param[in] other An object to be used as the source to initialize object
* Constructs a Parameter by copying input objects and parameters of another Parameter
* \param[in] other An object to be used as the source object to initialize from
*/
Parameter(const Parameter & other);

/**
* Assigns a Parameter by copying input objects and parameters of another Parameter
* \param[in] other An object to be used as the source object to copy from
*/
Parameter & operator=(const Parameter & other);

/**
* Checks the correctness of the parameter
*
Expand Down Expand Up @@ -129,6 +136,9 @@ class DAAL_EXPORT Input : public sum_of_functions::Input
/** Copy constructor */
Input(const Input & other);

/** Assignment operator */
Input & operator=(const Input & other);

/** Destructor */
virtual ~Input() {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,17 @@ struct DAAL_EXPORT Parameter : public sum_of_functions::Parameter
const DAAL_UINT64 resultsToCompute = objective_function::gradient);

/**
* Constructs an Parameter by copying input objects and parameters of another Parameter
* \param[in] other An object to be used as the source to initialize object
* Constructs a Parameter by copying input objects and parameters of another Parameter
* \param[in] other An object to be used as the source object to initialize from
*/
Parameter(const Parameter & other);

/**
* Assigns a Parameter by copying input objects and parameters of another Parameter
* \param[in] other An object to be used as the source object to copy from
*/
Parameter & operator=(const Parameter & other);

/**
* Checks the correctness of the parameter
*
Expand All @@ -148,6 +155,9 @@ class DAAL_EXPORT Input : public sum_of_functions::Input
/** Copy constructor */
Input(const Input & other);

/** Assignment operator */
Input & operator=(const Input & other);

/** Destructor */
virtual ~Input() {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,17 @@ struct DAAL_EXPORT Parameter : public daal::algorithms::Parameter
Parameter(const DAAL_UINT64 resultsToCompute = gradient);

/**
* Constructs an Parameter by copying input objects and parameters of another Parameter
* \param[in] other An object to be used as the source to initialize object
* Constructs a Parameter by copying input objects and parameters of another Parameter
* \param[in] other An object to be used as the source object to initialize from
*/
Parameter(const Parameter & other);

/**
* Assigns a Parameter by copying input objects and parameters of another Parameter
* \param[in] other An object to be used as the source object to copy from
*/
Parameter & operator=(const Parameter & other);

virtual ~Parameter() {}

DAAL_UINT64 resultsToCompute; /*!< 64 bit integer flag that indicates the results to compute */
Expand All @@ -144,6 +150,9 @@ class DAAL_EXPORT Input : public daal::algorithms::Input
/** Copy constructor */
Input(const Input & other);

/** Assignment operator */
Input & operator=(const Input & other);

/** Destructor */
virtual ~Input() {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,17 @@ struct DAAL_EXPORT Parameter : public objective_function::Parameter
const DAAL_UINT64 resultsToCompute = objective_function::gradient);

/**
* Constructs an Parameter by copying input objects and parameters of another Parameter
* \param[in] other An object to be used as the source to initialize object
* Constructs a Parameter by copying input objects and parameters of another Parameter
* \param[in] other An object to be used as the source object to initialize from
*/
Parameter(const Parameter & other);

/**
* Assigns a Parameter by copying input objects and parameters of another Parameter
* \param[in] other An object to be used as the source object to copy from
*/
Parameter & operator=(const Parameter & other);

/**
* Checks the correctness of the parameter
*
Expand Down Expand Up @@ -118,6 +124,9 @@ class DAAL_EXPORT Input : public objective_function::Input
/** Copy constructor */
Input(const Input & other);

/** Assignment operator */
Input & operator=(const Input & other);

/** Destructor */
virtual ~Input() {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ class DAAL_EXPORT Input : public optimization_solver::iterative_solver::Input
public:
Input();
Input(const Input & other);
Input & operator=(const Input & other);

using super::set;
using super::get;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,16 @@ Parameter::Parameter(const Parameter & other)
nClasses(other.nClasses)
{}

Parameter & Parameter::operator=(const Parameter & other)
{
sum_of_functions::Parameter::operator=(other);
this->interceptFlag = other.interceptFlag;
this->penaltyL1 = other.penaltyL1;
this->penaltyL2 = other.penaltyL2;
this->nClasses = other.nClasses;
return *this;
}

/**
* Checks the correctness of the parameter
*/
Expand All @@ -82,6 +92,12 @@ Input::Input() : sum_of_functions::Input(lastInputId + 1) {}

Input::Input(const Input & other) : sum_of_functions::Input(other) {}

Input & Input::operator=(const Input & other)
{
sum_of_functions::Input::operator=(other);
return *this;
}

/**
* Sets one input object for Logistic loss objective function
* \param[in] id Identifier of the input object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@ Parameter::Parameter(const Parameter & other)
: sum_of_functions::Parameter(other), penaltyL1(other.penaltyL1), penaltyL2(other.penaltyL2), interceptFlag(other.interceptFlag)
{}

Parameter & Parameter::operator=(const Parameter & other)
{
sum_of_functions::Parameter::operator=(other);
this->penaltyL1 = other.penaltyL1;
this->penaltyL2 = other.penaltyL2;
this->interceptFlag = other.interceptFlag;
return *this;
}

/**
* Checks the correctness of the parameter
*/
Expand All @@ -73,6 +82,12 @@ Input::Input() : sum_of_functions::Input(lastInputId + 1) {}

Input::Input(const Input & other) : sum_of_functions::Input(other) {}

Input & Input::operator=(const Input & other)
{
sum_of_functions::Input::operator=(other);
return *this;
}

/**
* Sets one input object for Logistic loss objective function
* \param[in] id Identifier of the input object
Expand Down
23 changes: 21 additions & 2 deletions cpp/daal/src/algorithms/objective_function/mse/mse_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,26 @@ Parameter::Parameter(size_t numberOfTerms, data_management::NumericTablePtr batc
{}

/**
* Constructs an Parameter by copying input objects and parameters of another Parameter
* \param[in] other An object to be used as the source to initialize object
* Constructs a Parameter by copying input objects and parameters of another Parameter
* \param[in] other An object to be used as the source object to initialize from
*/
Parameter::Parameter(const Parameter & other)
: sum_of_functions::Parameter(other), interceptFlag(other.interceptFlag), penaltyL1(other.penaltyL1), penaltyL2(other.penaltyL2)
{}

/**
* Assigns a Parameter by copying input objects and parameters of another Parameter
* \param[in] other An object to be used as the source object to copy from
*/
Parameter & Parameter::operator=(const Parameter & other)
{
sum_of_functions::Parameter::operator=(other);
this->interceptFlag = other.interceptFlag;
this->penaltyL1 = other.penaltyL1;
this->penaltyL2 = other.penaltyL2;
return *this;
}

/**
* Checks the correctness of the parameter
*/
Expand All @@ -74,6 +87,12 @@ Input::Input() : sum_of_functions::Input(lastInputId + 1) {}

Input::Input(const Input & other) : sum_of_functions::Input(other) {}

Input & Input::operator=(const Input & other)
{
sum_of_functions::Input::operator=(other);
return *this;
}

/**
* Sets one input object for Mean squared error objective function
* \param[in] id Identifier of the input object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,20 @@ Parameter::Parameter(const DAAL_UINT64 resultsToCompute) : resultsToCompute(resu

Parameter::Parameter(const Parameter & other) : resultsToCompute(other.resultsToCompute) {}

Parameter & Parameter::operator=(const Parameter & other)
{
this->resultsToCompute = other.resultsToCompute;
return *this;
}

/** Default constructor */
Input::Input(size_t n) : daal::algorithms::Input(n) {}
Input::Input(const Input & other) : daal::algorithms::Input(other) {}
Input & Input::operator=(const Input & other)
{
daal::algorithms::Input::operator=(other);
return *this;
}

/**
* Sets one input object for Objective function
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ Parameter::Parameter(const Parameter & other)
featureId(other.featureId)
{}

Parameter & Parameter::operator=(const Parameter & other)
{
objective_function::Parameter::operator=(other.resultsToCompute);
this->numberOfTerms = other.numberOfTerms;
this->batchIndices = other.batchIndices;
this->featureId = other.featureId;
return *this;
}

/**
* Checks the correctness of the parameter
*/
Expand All @@ -65,6 +74,12 @@ Input::Input(size_t n) : objective_function::Input(n) {}

Input::Input(const Input & other) : objective_function::Input(other) {}

Input & Input::operator=(const Input & other)
{
objective_function::Input::operator=(other);
return *this;
}

/**
* Sets one input object for Sum of functions
* \param[in] id Identifier of the input object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ services::Status Parameter::check() const

Input::Input() {}
Input::Input(const Input & other) {}
Input & Input::operator=(const Input & other)
{
return *this;
};

data_management::NumericTablePtr Input::get(OptionalDataId id) const
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ services::Status Parameter::check() const

Input::Input() {}
Input::Input(const Input & other) {}
Input & Input::operator=(const Input & other)
{
return *this;
};

services::Status Input::check(const daal::algorithms::Parameter * par, int method) const
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ services::Status Parameter::check() const

Input::Input() : daal::algorithms::Input(lastOptionalInputId + 1) {}
Input::Input(const Input & other) : daal::algorithms::Input(other) {}
Input & Input::operator=(const Input & other)
{
daal::algorithms::Input::operator=(other);
return *this;
}

data_management::NumericTablePtr Input::get(InputId id) const
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ services::Status Parameter::check() const

Input::Input() {}
Input::Input(const Input & other) {}
Input & Input::operator=(const Input & other)
{
return *this;
}

NumericTablePtr Input::get(OptionalDataId id) const
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ services::Status Parameter::check() const

Input::Input() {}
Input::Input(const Input & other) {}
Input & Input::operator=(const Input & other)
{
return *this;
}

data_management::NumericTablePtr Input::get(OptionalDataId id) const
{
Expand Down

0 comments on commit d43c4ab

Please sign in to comment.