Skip to content

Instantly share code, notes, and snippets.

#include <iostream>
#include <random>
#include <cmath>
uint8_t encode(float x)
{
int32_t t = static_cast<int32_t>(x*256);
return t<256? static_cast<uint8_t>(t) : 255;
}
@taqu
taqu / main.py
Created March 30, 2023 10:35
VAE
import os
import numpy as np
import torch
from torch import nn
from torch.nn import functional as F
from torch.autograd import Variable
from torch.utils.data import DataLoader,Dataset
from torchvision import transforms
from torchvision.datasets import MNIST
/**
@file SVD.cpp
@author t-sakai
@date 2017/06/02 create
*/
#include "SVD.h"
#include <stdio.h>
#include <limits>
namespace mmath
---
Language: Cpp
BasedOnStyle: Chromium
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
#AlignConsecutiveBitFields: false
AlignConsecutiveDeclarations: false
AlignConsecutiveMacros: false
AlignEscapedNewlines: DontAlign
@taqu
taqu / Regex.h
Created January 26, 2023 16:09
Simple regex for UE
#pragma once
#ifndef INC_REGEX_H_
# define INC_REGEX_H_
# include <CoreMinimal.h>
# include <Misc/CString.h>
namespace sregex
{
constexpr uint32 pow2(uint32 x, uint32 s)
int64_t m1 = 4294967087;
int64_t m2 = 4294944443;
int64_t a12 = 1403580;
int64_t a13n = 810728;
int64_t a21 = 527612;
int64_t a23n = 1370589;
int64_t s10, s11, s12, s20, s21, s22;
uint32_t MRG32k32a()
@taqu
taqu / ProjectTypes.cs
Last active October 9, 2022 13:57
Visual Studio project type GUIDs from DamianSuess/ProjectGuids.md
namespace
{
public static class ProjectTypes
{
public const string ASP_NET_5 = "{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}"; // ASP.NET 5
public const string ASP_NET_MVC_1 = "{603C0E0B-DB56-11DC-BE95-000D561079B0}"; // ASP.NET MVC 1
public const string ASP_NET_MVC_2 = "{F85E285D-A4E0-4152-9332-AB1D724D3325}"; // ASP.NET MVC 2
public const string ASP_NET_MVC_3 = "{E53F8FEA-EAE0-44A6-8774-FFD645390401}"; // ASP.NET MVC 3
public const string ASP_NET_MVC_4 = "{E3E379DF-F4C6-4180-9B81-6769533ABE47}"; // ASP.NET MVC 4
public const string ASP_NET_MVC_5 = "{349C5851-65DF-11DA-9384-00065B846F21}"; // ASP.NET MVC 5
@taqu
taqu / hash.c
Last active September 22, 2022 09:43
#include "tshash.h"
#ifdef _MSC_VER
#include <intrin.h>
#define TSHASH_RESTRICT(x) x __restrict
#else
#define TSHASH_RESTRICT(x) x __restrict__
#endif
#ifdef __cplusplus
@taqu
taqu / mul128.c
Last active September 21, 2022 03:32
#include <stdint.h>
#include <stdio.h>
#if defined(__GNUC__) || defined(__clang__)
void mul(uint64_t* high, uint64_t* low, uint64_t x0, uint64_t x1)
{
unsigned __int128 r = (unsigned __int128)x0 * (unsigned __int128)x1;
*high = r>>64;
*low = (uint64_t)r;
}
/**
*/
#include "crater.h"
#include <cassert>
#ifdef _WIN32
# include <Windows.h>
#endif
#define LAVA_VK_EXPORTED_FUNCTION(NAME) PFN_##NAME NAME;