Skip to content

Instantly share code, notes, and snippets.

// Preconditioned Conjugate Gradient
// 前処理付き共役勾配法
// Ax = b の方程式をxについて解く手法
// 前処理付き行列として Pinv * A ~ I
// になるような行列を渡す
void PCG( CvMat* A, CvMat* b, CvMat* x, CvMat* Pinv, double th);
void PCG( CvMat* A, CvMat* b, CvMat* x, CvMat* Pinv, double th)
{
@ginrou
ginrou / CompressiveSensing
Created January 31, 2012 03:55
内点法を用いた圧縮サンプリング
#include "compressiveSensing.h"
// private functions
void mulA( CSstruct *cs, CvMat* x, CvMat* y);
void mulPinv( CSstruct *cs, CvMat* x, CvMat* y);
void saveMat( CvMat *mat, char filename[] );
double min( double a, double b ){
return ( a<b )? a : b;
@ginrou
ginrou / npc.c
Created January 31, 2012 04:18
混合ガウス分布を用いたNPCのためのEMアルゴリズム
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <cv.h>
#include <highgui.h>
#define DIM 2 // 次元
@ginrou
ginrou / winner
Created April 19, 2012 23:32
ウィナーデコンボリューション
#include <stdio.h>
#include <cv.h>
#include <highgui.h>
int main( int argc, char *argv[] ){
double snr = 0.002;
// read file
if( argc == 1 ){
@ginrou
ginrou / UIView+frame.h
Created December 25, 2012 17:28
UIViewでtopとかrightとかで指定できるようにした拡張
#import <UIKit/UIKit.h>
@interface UIView (frame)
@property (nonatomic, assign) CGPoint origin;
@property (nonatomic, assign) CGFloat left;
@property (nonatomic, assign) CGFloat right;
@property (nonatomic, assign) CGFloat top;
@property (nonatomic, assign) CGFloat bottom;
@property (nonatomic, assign) CGSize size;
@ginrou
ginrou / gist:5221332
Last active December 15, 2015 07:09
UILabelを回転
- (void)rotateLabel:(UILabel* )label
{
CGAffineTransform transform = CGAffineTransformMakeRotation(M_PI_2); // 90度回転
// アニメーションなしで回転
label.transform = transform;
// 3.0[sec]かけて回転
[UIView animateWithDuration:1.0 animations:^{
label.transform = transform;
@ginrou
ginrou / gist:5618880
Created May 21, 2013 10:32
Perfect Python 10章 コマンドラインユーティリティ

ファイルの読み込み

bytes, str

文字列のフォーマット

その他のファイル処理モジュールなど

10.4 TODO リストを作る

データ構造

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// vc1をrootにしてUINavigationControllerの初期化
UIViewController *vc1 = [[UIViewController alloc] init];
UINavigationController *nc = [[UINavigationController alloc] initWithRootViewController:vc1];
// vc2で切り替える
UIViewController *vc2 = [[UIViewController alloc] init];
[nc setViewControllers:@[vc2]];
@ginrou
ginrou / UIImageView+CircleMask.h
Last active December 30, 2015 09:29
UIImageViewを円形にマスクをかける
#import <UIKit/UIKit.h>
@interface UIImageView (CircleMask)
- (void)circleMask;
- (void)circleMaskBorderWitdh:(CGFloat)width color:(CGColorRef)color;
@end
@ginrou
ginrou / panorama_stitching.cpp
Created July 18, 2012 12:31
パノラマ合成
#include <iostream>
#include <string>
#include <stdio.h>
#include <cv.h>
#include <highgui.h>
#include <opencv2/nonfree/nonfree.hpp>
#define SQUARE(x) ((x)*(x))