-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from ivanslapnicar/ivan/morematrices
Added more matrices ...
- Loading branch information
Showing
8 changed files
with
279 additions
and
46 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
julia 0.2- | ||
|
||
Polynomials 0.0.3 |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#### Cauchy matrix | ||
|
||
export Cauchy | ||
|
||
immutable Cauchy{T} <: AbstractMatrix{T} | ||
x::Vector{T} # | ||
y::Vector{T} # | ||
end # immutable | ||
|
||
function Cauchy(k::Number) | ||
Cauchy([1:k],[1:k]) | ||
end | ||
|
||
function Cauchy(x::Vector) | ||
Cauchy(x,x) | ||
end | ||
|
||
# Define its size | ||
|
||
size(A::Cauchy, dim::Integer) = length(A.x) | ||
size(A::Cauchy)= size(A,1), size(A,1) | ||
|
||
# Index into a Cauchy | ||
function getindex(A::Cauchy,i::Integer,j::Integer) | ||
return 1.0/(A.x[i]+A.y[j]) | ||
end # getindex | ||
|
||
# Dense version of Cauchy | ||
full(A::Cauchy) =[A[i,j] for i=1:size(A,1), j=1:size(A,2)] |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#### Kahan matrix | ||
|
||
export Kahan | ||
|
||
immutable Kahan{T<:Number,T1<:Number} <: AbstractMatrix{T} | ||
m::Int # dimension | ||
n::Int # dimension | ||
theta::T # angle | ||
pert::T1 # perturbation is pert*eps() | ||
end # immutable | ||
|
||
# Define its size | ||
size(A::Kahan, r::Int) = r==1 ? A.m : A.n | ||
size(A::Kahan) = A.m, A.n | ||
|
||
# Index into a Kahan | ||
function getindex(A::Kahan,i::Integer,j::Integer) | ||
m=minimum(size(A)) | ||
t=tan(A.theta) | ||
c=1.0/sqrt(1.0+t^2) | ||
s=t*c | ||
if i>m; return 0.0 | ||
elseif i>j; return 0.0 | ||
elseif i==j; return s^(i-1)+A.pert*eps()*(m-i+1) | ||
else return -c*s^(i-1) | ||
end | ||
end # getindex | ||
|
||
# Dense version of Kahan | ||
full(A::Kahan) =[A[i,j] for i=1:size(A,1), j=1:size(A,2)] | ||
|
||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#### Riemann Matrix | ||
import Base: size | ||
export Riemann | ||
|
||
immutable Riemann{Int} <: AbstractMatrix{Int} | ||
n::Int | ||
end # immutable | ||
|
||
# Define its size | ||
|
||
size(A::Riemann, dim::Integer) = A.n | ||
size(A::Riemann)= size(A,1), size(A,1) | ||
|
||
# Index into a Riemann | ||
function getindex(A::Riemann,i::Integer,j::Integer) | ||
# return (i+1)%(j+1)==0 ? i : -1 | ||
if i<=j && (j+1)%(i+1)==0 | ||
return i | ||
else | ||
return -1 | ||
end | ||
end # getindex | ||
|
||
# Dense version of Riemann | ||
full(A::Riemann) =[A[i,j] for i=1:size(A,1), j=1:size(A,2)] | ||
|