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
| import socket | |
| import base64 | |
| import cv2 | |
| UDP_IP = "127.0.0.1" | |
| UDP_PORT = 5005 | |
| cap = cv2.VideoCapture(0) | |
| while True: |
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
| //use "path:/src/main/lib" | |
| actor Main | |
| new create(env: Env) => | |
| env.out.print("Stuff") |
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
| // Compile with -std=c++1z and -ftemplate-depth=1025, may contain non–standard code, so GCC is preferred. | |
| #include <iostream> | |
| template<size_t n, int cnt = 3> | |
| constexpr bool is_prime_impl() { | |
| if constexpr(cnt >= n - 1) { | |
| return true; | |
| } else if constexpr(n % cnt == 0) { | |
| return false; | |
| } else { |
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
| /* SIMD */ | |
| #include <boost/simd/function/store.hpp> | |
| #include <boost/simd/function/load.hpp> | |
| #include <boost/simd/function/sum.hpp> | |
| #include <boost/simd/memory.hpp> | |
| #include <boost/simd/pack.hpp> | |
| /* SFML */ | |
| #include <SFML/System/Vector2.hpp> |
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 <boost/simd/function/load.hpp> | |
| #include <boost/simd/function/sum.hpp> | |
| #include <boost/simd/memory.hpp> | |
| #include <boost/simd/pack.hpp> | |
| #include <iostream> | |
| #include <vector> | |
| #include <chrono> | |
| /*Żeby było mniej pisania*/ | |
| namespace bs = boost::simd; |
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
| int main() { | |
| std::cout << "cardinal: " << cardinal << std::endl; | |
| constexpr auto size = 512; | |
| std::vector<float, bs::allocator<float>> vec1(size); | |
| std::vector<float, bs::allocator<float>> vec2(size); | |
| std::generate(vec1.begin(), vec1.end(), [](){return 5.f;}); | |
| std::generate(vec2.begin(), vec2.end(), [](){return .5f;}); |
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 <class allocator_t> | |
| float simd(std::vector<float, allocator_t>& a, std::vector<float, allocator_t>& b) { | |
| float sum = 0.f; | |
| /* Deklarujemy paczki */ | |
| pack_t pack1; | |
| pack_t pack2; | |
| auto i = 0u; | |
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
| /*Żeby było mniej pisania*/ | |
| namespace bs = boost::simd; | |
| /* Będziemy używać paczek trzymających zmienne typu float */ | |
| typedef bs::pack<float> pack_t; | |
| /* Stała (właściwie wyrażenie) cardinal będzie informować | |
| o tym ile zmiennych mieści się w jednej paczce */ | |
| constexpr auto cardinal = bs::cardinal_of<pack_t>(); |
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
| /* Dowolny alokator */ | |
| template <class allocator_t> | |
| /* Funkcja przyjmuje referencję na dwa wektory (z tym samym alokatorem) */ | |
| float linear(std::vector<float, allocator_t>& a, std::vector<float, allocator_t>& b) { | |
| float sum = 0.f; | |
| /* Jeśli jeden vector ma więcej elemntów niż drugi to je pomijamy */ | |
| for(auto i = 0u; i < std::min(a.size(), b.size()); ++i) { | |
| sum += a[i] * b[i]; | |
| } |
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 <cstdlib> | |
| #include <chrono> | |
| /* Measure time of function execution */ | |
| template<class Func> | |
| std::chrono::duration<double> measure(Func f) { | |
| auto point = std::chrono::high_resolution_clock::now(); | |
| f(); |
NewerOlder