mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-26 13:40:05 +00:00
c4805e0262
* issue/issue-281-create_binding_to_pedersen_hash * Add //nolint * Add more nolints * move nolint * Remove nolit * Add gcc install * Upd .ci * Remove staticcheck * Add envs * try to exclude pedersen_hash from test * try to fix mac os build * Add include for mac os * Add include for mac os * Fix runner_os * remove test for macos * Change restrictions * restrict tests to ubuntu * Try test windows * Add build constraint
43 lines
1.7 KiB
C++
43 lines
1.7 KiB
C++
#include "fraction_field_element.h"
|
|
|
|
#include "error_handling.h"
|
|
|
|
namespace starkware {
|
|
|
|
template <typename FieldElementT>
|
|
FractionFieldElement<FieldElementT> FractionFieldElement<FieldElementT>::operator+(
|
|
const FractionFieldElement<FieldElementT>& rhs) const {
|
|
const auto num_value = this->numerator_ * rhs.denominator_ + this->denominator_ * rhs.numerator_;
|
|
const auto denom_value = this->denominator_ * rhs.denominator_;
|
|
return FractionFieldElement(num_value, denom_value);
|
|
}
|
|
|
|
template <typename FieldElementT>
|
|
FractionFieldElement<FieldElementT> FractionFieldElement<FieldElementT>::operator-(
|
|
const FractionFieldElement<FieldElementT>& rhs) const {
|
|
const auto num_value = this->numerator_ * rhs.denominator_ - this->denominator_ * rhs.numerator_;
|
|
const auto denom_value = this->denominator_ * rhs.denominator_;
|
|
return FractionFieldElement(num_value, denom_value);
|
|
}
|
|
|
|
template <typename FieldElementT>
|
|
FractionFieldElement<FieldElementT> FractionFieldElement<FieldElementT>::operator*(
|
|
const FractionFieldElement<FieldElementT>& rhs) const {
|
|
return FractionFieldElement(
|
|
this->numerator_ * rhs.numerator_, this->denominator_ * rhs.denominator_);
|
|
}
|
|
|
|
template <typename FieldElementT>
|
|
bool FractionFieldElement<FieldElementT>::operator==(
|
|
const FractionFieldElement<FieldElementT>& rhs) const {
|
|
return this->numerator_ * rhs.denominator_ == this->denominator_ * rhs.numerator_;
|
|
}
|
|
|
|
template <typename FieldElementT>
|
|
FractionFieldElement<FieldElementT> FractionFieldElement<FieldElementT>::Inverse() const {
|
|
ASSERT(this->numerator_ != FieldElementT::Zero(), "Zero does not have an inverse");
|
|
return FractionFieldElement(denominator_, numerator_);
|
|
}
|
|
|
|
} // namespace starkware
|