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
from io import StringIO | |
import sys | |
old_stdout = sys.stdout | |
sys.stdout = mystdout = StringIO() | |
# blah blah lots of code ... | |
print("fuck me god") | |
sys.stdout = old_stdout |
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
MPI实践起来真是有点困难,因为好多外国网站上不去,只能自己摸索: | |
1.setup mpich2 | |
mpiexec -remove to remove account for each computer node | |
mpiexec -register to add account for each computer 'node' | |
mpiexec -validate to validate the account | |
Notice ,you must create a account(username/password all same) for all nodes on windows. | |
2.build boost.mpi | |
修改boost_1_47_0\tools\build\v2\tools\mpi.jam文件,修改的地方如下: |
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
# -*- encoding=UTF-8 -*- | |
#!/usr/bin/env python | |
from Hello import *; # import internal c++ module | |
a = World() | |
a.set("Liudx") | |
print("Hello", a.greet()) | |
print(identity(red), identity(color(2)), identity(color.blue)) | |
k = a.t | |
k.a = 10; |
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
Show hidden characters
{ | |
"cmd": ["g++", "-std=c++1y", "${file}", "-O2", "-Wall", "-o", "${file_path}/${file_base_name}"], // For GCC On Windows and Linux | |
//"cmd": ["CL", "/Fo${file_base_name}", "/O2", "${file}"], // For CL on Windows Only | |
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$", | |
"working_dir": "${file_path}", | |
"selector": "source.c, source.c++", | |
"variants": | |
[ | |
{ |
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
Fibonacci f(n+1)=f(n)+f(n-1) n >= 1 | |
1. sum(f(n)^2) = f(n)*f(n+1) | |
证明如下,面积之和相等 | |
# 绘图代码如下 | |
import matplotlib.pyplot as plt | |
from matplotlib.path import Path | |
import matplotlib.patches as patches |
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
# -*- coding:UTF-8 -*- | |
#!/usr/bin/env python | |
''' | |
Clear the directory using filter | |
''' | |
import os.path | |
import sys,os | |
import stat | |
import re |
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 <vector> | |
#include <iostream> | |
#include "d:/workspace/dxh/testUlt.h" | |
using namespace std; | |
//计算二项式系数C(n,k) | |
int Binomial(int n, int k) { | |
int result[n + 1][k + 1]; | |
for(int i = 0; i <= n; ++i) //按行来填矩阵 | |
{ |
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 <cstdio> | |
#include <map> | |
#include <algorithm> | |
using namespace std; | |
// 双射函数 | |
// proven : | |
// as |
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
#lang racket | |
; applicative-order Y-combinator. | |
; Y: The function that takes a function f and returns f (f (f (f (···)))) | |
(define Y | |
(lambda (le) | |
((lambda (f) (f f)) | |
(lambda (f) | |
(le (lambda (x) ((f f) x))))))) | |
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
#lang racket | |
;;; 以下三个定义 env0, ent-env, lookup 是对环境(environment)的基本操作: | |
;; 空环境 | |
(define env0 '()) | |
;; 扩展。对环境 env 进行扩展,把 x 映射到 v,得到一个新的环境 | |
(define ext-env | |
(lambda (x v env) | |
(cons `(,x . ,v) env))) |
NewerOlder