This commit is contained in:
tovjemam 2025-12-04 10:09:44 +01:00
parent f3df308366
commit e6a6de048d
7 changed files with 34 additions and 42 deletions

View File

@ -4,5 +4,6 @@ PointerAlignment: Left
IndentWidth: 4 # spaces per indent level
TabWidth: 4 # width of a tab character
UseTab: Never # options: Never, ForIndentation, Alwayss
AccessModifierOffset: -4
BreakTemplateDeclarations: Yes
AllowShortFunctionsOnASingleLine: Inline

View File

@ -2,8 +2,8 @@
#include <limits>
#include "utils.hpp"
#include "storage.hpp"
#include "utils.hpp"
namespace mp
{
@ -71,10 +71,7 @@ class BasicInt
*this = value;
}
BasicInt(const char* str)
{
*this = str;
}
BasicInt(const char* str) { *this = str; }
template <AnyMpInt T>
requires ElementTypesMatch<T, BasicInt>
@ -148,10 +145,7 @@ class BasicInt
TElem& operator[](size_t index) { return m_data[index]; }
const TElem& operator[](size_t index) const { return m_data[index]; }
void resize(size_t new_size)
{
m_data.resize(new_size);
}
void resize(size_t new_size) { m_data.resize(new_size); }
void zero() { m_data.clear(); }

View File

@ -1,11 +1,11 @@
#pragma once
#include <algorithm>
#include <string>
#include <stdexcept>
#include <string>
#include "utils.hpp"
#include "int.hpp"
#include "utils.hpp"
namespace mp
{
@ -38,7 +38,6 @@ inline std::string to_hex_string(const T& number)
}
return "0x0";
}
template <AnyMpInt T>
@ -64,7 +63,8 @@ inline std::string to_string(const T& number)
{
std::string str;
T temp = number;
do {
do
{
auto rem = div_mod(temp, 10U);
str.push_back(static_cast<char>('0' + rem));
} while (temp != 0U);
@ -109,7 +109,6 @@ inline T factorial(const T& n)
return result;
}
// template <AnyInt T>
// inline T parse_string(const char* str)
// {
@ -118,4 +117,4 @@ inline T factorial(const T& n)
// return number;
// }
}
} // namespace mp

View File

@ -279,8 +279,6 @@ struct Subtraction
add_ignore_sign(lhs, rhs, res);
res.set_negative(false);
}
}
};
@ -462,7 +460,8 @@ struct Division
LongerType carry_add = 0;
for (size_t i = 0; i < n; ++i)
{
LongerType sum = static_cast<LongerType>(u.get(j + i)) + static_cast<LongerType>(v.get(i)) + carry_add;
LongerType sum =
static_cast<LongerType>(u.get(j + i)) + static_cast<LongerType>(v.get(i)) + carry_add;
u.set(j + i, static_cast<ElementType>(sum & MASK));
carry_add = sum >> W;
}
@ -571,5 +570,4 @@ TLhs& operator/=(TLhs& lhs, const TRhs& rhs)
return ca_binary_op<Division>(lhs, rhs);
}
} // namespace mp

View File

@ -1,5 +1,5 @@
#pragma once
#include "int.hpp"
#include "math.hpp"
#include "lib.hpp"
#include "math.hpp"

View File

@ -64,7 +64,7 @@ class VectorContainer
constexpr size_t MAX_ARRAY_BYTES = 128;
template <typename TElem, size_t MaxSize>
using Container =
std::conditional_t<(MaxSize > MAX_ARRAY_BYTES / sizeof(TElem)), VectorContainer<TElem, MaxSize>, ArrayContainer<TElem, MaxSize>>;
using Container = std::conditional_t<(MaxSize > MAX_ARRAY_BYTES / sizeof(TElem)), VectorContainer<TElem, MaxSize>,
ArrayContainer<TElem, MaxSize>>;
} // namespace mp

View File

@ -137,4 +137,4 @@ constexpr TElem calculate_last_elem_mask()
return mask;
}
}
} // namespace mp