2009-07-01から1ヶ月間の記事一覧

文字列並び替え

辞書順に並び替える。codepadで実行可。 #!/usr/bin/perl @categories = qw( # ここに文字列をかく hoge piyo ); # 並び替え @categories = sort {"\L$a" cmp "\L$b"} @categories; # 出力 foreach $each(@categories) { print $each . "\n"; }

shellでファイル操作+while文+変数操作

採点作業用に作ったやつ #!/bin/sh FILE=list.txt while read LINE do echo $LINE id=$(echo $LINE | sed "s/DirRegExp\///g") dir=$(echo $LINE | sed "s/\/FileRegExp//g") echo mkdir $id echo "cp $dir/* $id" done < $FILE list.txt Directory_01/Stude…

MIE環境の設定作業ログ

HPがカスタマイズしたUbuntu「MIE」を、 自分が使いやすいようにいじったときのログ 言語を日本語にする デフォルト言語が英語だったので、 「System Settings」-->「Language Support」で言語を日本語に設定した。 キーボード配列を日本語配列にする そのま…

32ビット固定小数3次元ベクトルクラス

C++

#ifndef VECTOR3FIX_H #define VECTOR3FIX_H #include <iostream> #include <math.h> class Vector3fix { public: int x; int y; int z; Vector3fix() : x(0), y(0), z(0) {} Vector3fix(int x, int y, int z) : x(x << 16), y(y << 16), z(z << 16) {} Vector3fix(float x, fl</math.h></iostream>…

32ビット固定小数の精度

上位16ビットを整数部、下位16ビットを小数部とすると、 扱える値の範囲は整数部で -32768 ~ +32767 小数部で 0.0000152587891 ~ 0.999984741 【考察】 整数演算ユニットが使えるので、処理速度は浮動小数より速くなると思われる。 浮動小数に比べると精度…

32ビット単精度浮動小数3次元ベクトルクラス

C++

#ifndef VECTOR3F_H #define VECTOR3F_H #include <iostream> #include <math.h> class Vector3f { public: float x; float y; float z; Vector3f() : x(0.0f), y(0.0f), z(0.0f) {} Vector3f(float x, float y, float z) : x(x), y(y), z(z) {} Vector3f(const Vector3f& star</math.h></iostream>…