Skip to content

Instantly share code, notes, and snippets.

View zhanghuimeng's full-sized avatar

Huimeng Zhang zhanghuimeng

View GitHub Profile
@zhanghuimeng
zhanghuimeng / CG_Line_Circle_Antialised_usingOpenCV.cpp
Last active March 19, 2017 06:15
Using OpenCV 3 to practice draw lines and circles in a Raster Graphics manner. Antialias included.
#include <vector>
#include <iostream>
#include <opencv2/opencv.hpp>
#include <cmath>
using namespace std;
using namespace cv;
const int width = 1500, height = 1500;
const Vec3b BLACK(0, 0, 0), WHITE(255, 255, 255), BLUE(255, 0, 0),
@zhanghuimeng
zhanghuimeng / report_template.tex
Last active February 23, 2020 14:12
数值分析实验报告模板
% !Mode:: "TeX:UTF-8"
\documentclass{article}
\usepackage[hyperref, UTF8]{ctex}
\usepackage[dvipsnames]{xcolor}
\usepackage{geometry}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{listings}
\usepackage{pgfplotstable}
\usepackage{pgfplots}
@zhanghuimeng
zhanghuimeng / interactive_window.cpp
Created May 26, 2017 06:26
opencv鼠标笔刷标记区域
// 1. 一些基本定义
typedef cv::Vec3b Color;
typedef cv::Mat_<Color> Image;
Image img; // 要处理的那张图
struct MouseArgs // 用于和回调函数交互,至于为什么要特意攒一个struct后面会讲~
{
Image &img; // 显示在窗口中的那张图
std::vector<std::vector<int>> &mask; // 用户绘制的选区(删除/保留)
@zhanghuimeng
zhanghuimeng / 1-3.cpp
Last active April 3, 2019 10:44
数值分析实验报告模板
#include <iostream>
#include <cstdio>
#include <ctime>
#include <iomanip>
using namespace std;
int main()
{
// 你好,世界!
- to be continued...
@zhanghuimeng
zhanghuimeng / DIV.vhd
Last active February 3, 2018 04:04
NewThinpadProject/simulation/srcs
/* DIV Module */
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use WORK.INCLUDE.ALL;
entity DIV is
Port ( rst: in STD_LOGIC; -- Reset
clk: in STD_LOGIC; -- Clock
@zhanghuimeng
zhanghuimeng / miller-rabin.py
Last active January 6, 2021 14:36
Miller-Rabin素性检验
import random
import argparse
smallPrimeList = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59,
61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139,
149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229,
233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317,
331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421,
431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521,
523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619,
@zhanghuimeng
zhanghuimeng / softmax_cross_entropy.py
Last active February 28, 2022 13:41
The numerical stability of Softmax and Cross Entropy
import numpy as np
from scipy.special import expit
import math
EPS = 1e-9
MAX_EXP = 709
def softmax(x):
exp_x = np.exp(x - np.max(x))
return exp_x / exp_x.sum()