This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
void print(const std::vector<std::vector<int>> &vec) { | |
std::cout << "sizeof(int): " << sizeof(int) << '\n'; | |
std::cout << "sizeof(std::vector<int>(10)): " << sizeof(std::vector<int>(10)) << '\n'; | |
for(const auto & r : vec) { | |
std::cout << "Row address: " << &(r) << '\n'; | |
for(const auto & c : r) { | |
std::cout << &(c) << ", "; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const size_t SIZE = 1000000; | |
void fill(int *arr) { | |
for(size_t i = 0; i < SIZE; ++i) { | |
arr[i] = i; | |
} | |
} | |
static void Heap(benchmark::State& state) { | |
int * test = new int[SIZE]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
void print(const std::vector<int> &vec) { | |
std::cout << "sizeof(int): " << sizeof(int) << ' '; | |
for(const auto & e : vec) { | |
std::cout << &(e) << ", "; | |
} | |
std::cout << std::endl; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pointer | |
_M_allocate(size_t __n) | |
{ | |
typedef __gnu_cxx::__alloc_traits<_Tp_alloc_type> _Tr; | |
return __n != 0 ? _Tr::allocate(_M_impl, __n) : pointer(); //(3) | |
} | |
void | |
_M_create_storage(size_t __n) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template<typename T> | |
class Matrix { | |
static_assert(std::is_arithmetic<T>::value, "T must be numeric"); | |
public: | |
Matrix(size_t rows, size_t columns, T *m) | |
: nbRows(rows), nbColumns(columns) | |
{ | |
matrix.resize(nbRows); | |
for(size_t rowIndex = 0; rowIndex < nbRows; ++rowIndex) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <vector> | |
#include <array> | |
#include <random> | |
#include <memory> | |
#include <algorithm> | |
const size_t COLUMNS = 500; | |
const size_t ROWS = 500; | |
static void TwoDimVector(benchmark::State& state) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// etokensign.cpp : This file contains the 'main' function. Program execution begins and ends there. | |
// Source and thanks to draketb https://stackoverflow.com/a/47894907/1541782 | |
#include <windows.h> | |
#include <cryptuiapi.h> | |
#include <iostream> | |
#include <string> | |
const std::wstring ETOKEN_BASE_CRYPT_PROV_NAME = L"eToken Base Cryptographic Provider"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Bisection : public Iteration { | |
public: | |
Bisection(double epsilon, const std::function<double (double)> &f) : Iteration(epsilon), mf(f) {} | |
double solve(double a, double b) override { | |
resetNumberOfIterations(); | |
checkAndFixAlgorithmCriteria(a, b); | |
fmt::print("Bisection -> [{:}, {:}]\n", a, b); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class LegendrePolynomial { | |
public: | |
LegendrePolynomial(double lowerBound, double upperBound, size_t numberOfIterations) | |
: mLowerBound(lowerBound), mUpperBound(upperBound), mNumberOfIterations(numberOfIterations), mWeight(numberOfIterations+1), mRoot(numberOfIterations+1) { | |
calculateWeightAndRoot(); | |
} | |
const std::vector<double> & getWeight() const { | |
return mWeight; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
std::vector<std::vector<double>> rombergIntegral(double a, double b, size_t n, const std::function<double (double)> &f) { | |
std::vector<std::vector<double>> romberg_integral(n, std::vector<double>(n)); | |
//R(0,0) Start with trapezoidal integration with N = 1 | |
romberg_integral.front().front() = trapezoidalIntegral(a, b, 1, f); | |
double h = b-a; | |
for(size_t step = 1; step < n; step++) { | |
h *= 0.5; |