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
function x = shifted_bicg(A, b, sigma, tol, max_iter) | |
%%% initialization | |
if nargin < 4 | |
tol = 1e-6; | |
max_iter = 1000; | |
end | |
if nargin < 5 | |
max_iter = 1000; |
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
object Strassen { | |
def add0(m:Array[Array[Double]], size:Int) = { | |
val log2 = Math.ceil(Math.log(size) / Math.log(2)).toInt | |
val next = Math.pow(2, log2).toInt | |
val res = Array.ofDim[Double](next, next) | |
for (i <- 0 until m.length) { | |
for (j <- 0 until m(0).length) { | |
res(i)(j) = m(i)(j) | |
} |
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
import scala.io._ | |
def readmtx (file:String) = { | |
val source = Source.fromFile(file,"UTF-8").getLines.toList | |
val lines = source.filter(x => x.head != '%') | |
val info = ((lines(0)) split "[ ]+").map(x => x.toInt) | |
val mat = Array.ofDim[Double] (info(0), info(1)) | |
for(i <- lines){ |
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
//MinGWのg++.exeでは、コンパイルは通るが実行した瞬間落ちる。 | |
//Visual C++ 2010 Express に付いてきたcl.exeでは動く。 | |
/* | |
g++ -vの出力 | |
Using built-in specs. | |
COLLECT_GCC=D:\Applications\MinGW\bin\g++.exe | |
COLLECT_LTO_WRAPPER=d:/applications/mingw/bin/../libexec/gcc/mingw32/4.7.0/lto-wrapper.exe | |
Target: mingw32 | |
Configured with: ../gcc-4.7.0/configure --enable-languages=c,c++,ada,fortran,objc,obj-c++ --disable-sjlj-exceptions --wi |
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
{-ラプラス方程式を解く-} | |
import Data.Array.IO | |
{-パラメータ設定-} | |
n = 50 {-行列のサイズ-} | |
k = (n+2) {-境界を含めた行列のサイズ-} | |
loop u 0 = return () | |
loop u n = do | |
writeArray u (1,n) 100 |
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
function say{ | |
$a = [Reflection.Assembly]::LoadWithPartialName('System.Speech') | |
$message = New-Object System.Speech.Synthesis.SpeechSynthesizer | |
$message.Speak($args) | |
} |
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
function tex2pdf([string]$filename, [switch]$nolog){ | |
$pdfname = $filename -replace ".tex", ".pdf" | |
$psinfo = ps | Where-Object{$_.MainWindowTitle -like "*"+ $pdfname +"*"} | |
if($psinfo -ne $NULL){ | |
foreach($a in $psinfo){ | |
kill $a.Id | |
} | |
} | |
platex $filename | |
$newfilename = $filename -replace ".tex", ".dvi" |
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
def main(): | |
filename = "guki.c" | |
f = open(filename, "w") | |
f.write("#include<stdio.h>\n") | |
f.write("#include<stdlib.h>\n\n") | |
f.write("int a(b){\n") | |
f.write(" int res;\n") | |
f.write(" switch(b){\n") | |
i = 0 | |
while i < 1000: |
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
function RemovePath{ | |
$p = pwd | |
$name = "Path" | |
sl HKCU: | |
$s = Get-ItemProperty "HKCU:Environment" $name | |
sl $p | |
$s = $s.$name | |
if($s[-1] -eq ";"){ | |
$s = $s.Remove($s.length - 1, 1) | |
} |
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
function AddPath([string]$x){ | |
$p = pwd | |
$name = "Path" | |
sl HKCU: | |
$s = Get-ItemProperty "HKCU:Environment" $name | |
sl $p | |
$s = $s.$name | |
Write-Host "path length:" $s.length + $x.length | |
if(($s.length -eq 0) -or ($s[-1] -eq ";")){ | |
$s += $x |
NewerOlder