1
0
mirror of https://github.com/kalmarek/PropertyT.jl.git synced 2024-11-19 07:20:28 +01:00

Rationalizing properly done

This commit is contained in:
kalmar 2017-01-09 00:59:40 +01:00
parent ce2ebc7284
commit 53dec056e0
2 changed files with 14 additions and 1 deletions

View File

@ -2,7 +2,7 @@ module GroupAlgebras
import Base: convert, show, isequal, == import Base: convert, show, isequal, ==
import Base: +, -, *, // import Base: +, -, *, //
import Base: size, length, norm import Base: size, length, norm, rationalize
export GroupAlgebraElement export GroupAlgebraElement
@ -112,4 +112,10 @@ length(X::GroupAlgebraElement) = length(X.coefficients)
size(X::GroupAlgebraElement) = size(X.coefficients) size(X::GroupAlgebraElement) = size(X.coefficients)
norm(X::GroupAlgebraElement, p=2) = norm(X.coefficients, p) norm(X::GroupAlgebraElement, p=2) = norm(X.coefficients, p)
rationalize{T<:Integer, S<:Number}(::Type{T}, X::GroupAlgebraElement{S};
tol=eps(S)) =
GroupAlgebraElement(
rationalize(T, X.coefficients, tol=tol), X.product_matrix)
end end

View File

@ -1,4 +1,5 @@
using JuMP using JuMP
import Base: rationalize
function products{T<:Real}(S1::Array{Array{T,2},1}, S2::Array{Array{T,2},1}) function products{T<:Real}(S1::Array{Array{T,2},1}, S2::Array{Array{T,2},1})
result = [0*similar(S1[1])] result = [0*similar(S1[1])]
@ -109,3 +110,9 @@ function correct_to_augmentation_ideal{T<:Rational}(sqrt_matrix::Array{T,2})
end end
return sqrt_corrected return sqrt_corrected
end end
function rationalize{T<:Integer, S<:Real}(::Type{T},
X::AbstractArray{S}; tol::Real=eps(eltype(X)))
r(x) = rationalize(T, x, tol=tol)
return r.(X)
end