function x = conjgrad(A,b,tol)
% CONJGRAD Conjugate Gradient Method.
% X = CONJGRAD(A,B) attemps to solve the system of linear equations A*X=B
% for X. The N-by-N coefficient matrix A must be symmetric and the right
% hand side column vector B must have length N.
%
% X = CONJGRAD(A,B,TOL) specifies the tolerance of the method. The
% default is 1e-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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
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
#!/bin/sh | |
# | |
# Orinally made by Lovell Fuller for sharp | |
# https://github.com/lovell/sharp | |
# | |
# Usage: | |
# curl -s https://gist.githubusercontent.com/h2non/89bb2f87c6499d0b25f1/raw/bf3d0743107f02f5db2b93c53f7f0e07a1c33112/libvips-installer.sh | sudo bash - | |
# |
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<stdio.h> | |
main(){ | |
long i,j,N=4,NRHS=1,IPIV[N],LDA=N,LDB=N,INFO; | |
double A[N*N],b[N]; | |
/* 変数の説明 N:変数の数 NRHS:右辺の列数 IPIV[N]:Pivot選択の情報 | |
LDA:左辺の行数 LDB:右辺の行数 INFO:ルーチンが成功したかどうかを返す */ | |
/* 配列の引数は列に対して連続になるようにする(例:1行1列の次は2行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
/* 三重対角行列を係数行列に持つ連立一次方程式の数値解法(掃き出し法) */ | |
/* 係数行列A=(a_{i,j})はa_{i,j}=2(if i==j),-1(if |i-j|==1),0(otherwise)である。*/ | |
/* これは1次元微分方程式の離散化ではよく見かける形式である */ | |
#include<stdio.h> | |
main(){ | |
int i,j; | |
long N=10,NRHS=1,IPIV[N],LDA=N,LDB=N,INFO; | |
double DL[N-1],D[N],DU[N-1],b[N],h=1./N,hs=h*h; |
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
(defun _null (x) | |
(eq x NIL)) | |
(defun _or (x y) | |
(if x t (if y t NIL))) | |
(defun _not (x) | |
(if x NIL t)) | |
(defun _and (x y) |
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
(load "blockdata.lsp") | |
(load "helper.lsp") | |
(defun match-element (x y) | |
(or (equal x y) (equal y '?))) | |
(defun match-triple (x pat) | |
(every #'match-element x pat)) |
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
(load "blockdata.lsp") | |
(defun match-element (x y) | |
(or (eq x y) (eq y '?))) | |
(match-element 1 1) | |
(match-element 1 2) | |
(match-element 1 '?) | |
(defun match-triple (x pat) |
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
Venue.where("latitude IS NULL").map{|v| v.latitude = v.location.lat; v.longitude = v.location.lng;v.save } | |
Venue.where("latitude IS NULL"). | |
Venue.where("dbapp_id IS NULL").each do |v| | |
lat_lng = GogoMaps.get_latlng(v.location.to_pretty_full) rescue next | |
v.latitude = lat_lng[:lat] | |
v.longitude = lat_lng[:lng] | |
v.save | |
end |
require 'benchmark'
print 'cos '; puts Benchmark.realtime { 10_000_000.times { Math.cos 1 }}
print 'sin '; puts Benchmark.realtime { 10_000_000.times { Math.sin 1 }}
print 'tan '; puts Benchmark.realtime { 10_000_000.times { Math.tan 1 }}
print 'acos '; puts Benchmark.realtime { 10_000_000.times { Math.acos 1 }}
print 'asin '; puts Benchmark.realtime { 10_000_000.times { Math.asin 1 }}
print 'atan '; puts Benchmark.realtime { 10_000_000.times { Math.atan 1 }}
NewerOlder