This file contains 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
// -First idea was to do it thanks to RAII. Problem is it requires a lot of brackets | |
// -Then i wanted to go full variadic generic template function, | |
// but i got stuck because i would have to pass a variadic function | |
// to a function which doesn't make any sense, and was overkill | |
// - This solution seems the best for now... Client code is okay-ish... | |
#include <iostream> | |
#include <chrono> | |
#include <thread> | |
#include <string> |
This file contains 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 <string> | |
#include <vector> | |
enum yearTypeT | |
{ | |
COMMON = 0, LEAP | |
}; | |
using yearT = unsigned int; |
This file contains 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
Latency Comparison Numbers | |
-------------------------- | |
L1 cache reference 0.5 ns | |
Branch mispredict 5 ns | |
L2 cache reference 7 ns 14x L1 cache | |
Mutex lock/unlock 25 ns | |
Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
Compress 1K bytes with Zippy 3,000 ns 3 us | |
Send 1K bytes over 1 Gbps network 10,000 ns 10 us | |
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD |
This file contains 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
(Written as a way to stop forgetting these things. | |
May be wrong sometimes, as it's just the result of my research here and there. | |
If it helps you, give me a shout!) | |
Ordered dithering is a technique used to reduce - deliberately! - the precision of an image. | |
Motivation : artistic (mainly ?), color quantization --> reduce the number of color in an image | |
---------------------------------------------------------------- | |
INTRODUCTION |
This file contains 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 <string> | |
#include <vector> | |
#include <cassert> | |
using uint = unsigned int; | |
template<typename T> | |
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) | |
{ |
This file contains 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
// Works with C++14 compiler | |
// Had to use my own array instead of std::array but with a C++17 compiler, it "should work" (tm) without it. | |
// Also, could use some static_assert here and there.... | |
#include <iostream> | |
#include <cmath> | |
using namespace std; | |
constexpr float halton(int i, int base) | |
{ |
This file contains 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> | |
#include <random> | |
#include <string> | |
#include <cmath> | |
#include <chrono> | |
using namespace std; | |
using namespace std::chrono; |
This file contains 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
// Credits to "Mon Chic Prof" Pat for the Lines trick. | |
// This contains clever things, and other not so much. | |
// But it does the job, and we sometimes need ugliness in order to appreciate the beauty of things. | |
#include <iostream> | |
#include <vector> | |
#include <string> | |
#include <chrono> | |
#include <fstream> | |
#include <string> |
This file contains 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
// """"Should"""" work with any C+14 compiler | |
// (And yes, there is a beautiful UB in this code) | |
#include <iostream> | |
struct Endianness | |
{ | |
constexpr static bool isBig() | |
{ | |
union |
This file contains 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 <algorithm> | |
#include <string> | |
#include <memory> | |
#include <vector> | |
using namespace std; | |
using u32 = unsigned int; | |
using s32 = int; |
OlderNewer