|
| 1 | +## Fun |
| 2 | + |
| 3 | +show(io::IO, ::MIME"text/plain", f::Fun) = show(io, f) |
| 4 | + |
| 5 | +function show(io::IO, f::Fun) |
| 6 | + print(io,"Fun(") |
| 7 | + show(io,space(f)) |
| 8 | + print(io,", ") |
| 9 | + show(io,coefficients(f)) |
| 10 | + print(io,")") |
| 11 | +end |
| 12 | + |
| 13 | +show(io::IO,f::Fun{<:ConstantSpace{AnyDomain}}) = |
| 14 | + print(io,"$(convert(Number,f)) anywhere") |
| 15 | + |
| 16 | +show(io::IO,f::Fun{<:ConstantSpace}) = |
| 17 | + print(io,"$(convert(Number,f)) on $(domain(f))") |
| 18 | + |
| 19 | +## MultivariateFun |
| 20 | + |
| 21 | +show(io::IO, ::MIME"text/plain", f::MultivariateFun) = show(io, f) |
| 22 | + |
| 23 | +function show(io::IO,L::LowRankFun) |
| 24 | + print(io,"LowRankFun on ",space(L)," of rank ",rank(L),".") |
| 25 | +end |
| 26 | + |
| 27 | +function show(io::IO,P::ProductFun) |
| 28 | + print(io,"ProductFun on ",space(P),".") |
| 29 | +end |
| 30 | + |
| 31 | +## Operator |
| 32 | + |
| 33 | +summarystr(B::Operator) = string(typeof(B).name.name, " : ", domainspace(B), " → ", rangespace(B)) |
| 34 | +summary(io::IO, B::Operator) = print(io, summarystr(B)) |
| 35 | + |
| 36 | +struct PrintShow |
| 37 | + str |
| 38 | +end |
| 39 | +Base.show(io::IO,N::PrintShow) = print(io,N.str) |
| 40 | + |
| 41 | +show(io::IO, B::Operator) = summary(io, B) |
| 42 | + |
| 43 | +function show(io::IO, ::MIME"text/plain", B::Operator;header::Bool=true) |
| 44 | + header && summary(io, B) |
| 45 | + dsp = domainspace(B) |
| 46 | + |
| 47 | + if !isambiguous(domainspace(B)) && (eltype(B) <: Number) |
| 48 | + println() |
| 49 | + if isbanded(B) && isinf(size(B,1)) && isinf(size(B,2)) |
| 50 | + BM=B[1:10,1:10] |
| 51 | + |
| 52 | + M=Matrix{Any}(undef,11,11) |
| 53 | + fill!(M,PrintShow("⋅")) |
| 54 | + for j = 1:size(BM,2),k = colrange(BM,j) |
| 55 | + M[k,j]=BM[k,j] |
| 56 | + end |
| 57 | + |
| 58 | + for k=max(1,11-bandwidth(B,2)):11 |
| 59 | + M[k,end]=PrintShow("⋱") |
| 60 | + end |
| 61 | + for j=max(1,11-bandwidth(B,1)):10 |
| 62 | + M[end,j]=PrintShow("⋱") |
| 63 | + end |
| 64 | + |
| 65 | + print_array(io, M) |
| 66 | + elseif isinf(size(B,1)) && isinf(size(B,2)) |
| 67 | + BM=B[1:10,1:10] |
| 68 | + |
| 69 | + M=Matrix{Any}(undef,11,11) |
| 70 | + for k=1:10,j=1:10 |
| 71 | + M[k,j]=BM[k,j] |
| 72 | + end |
| 73 | + |
| 74 | + M[1,end]=PrintShow("⋯") |
| 75 | + M[end,1]=PrintShow("⋮") |
| 76 | + |
| 77 | + for k=2:11 |
| 78 | + M[k,end]=M[end,k]=PrintShow("⋱") |
| 79 | + end |
| 80 | + |
| 81 | + print_array(io, M) |
| 82 | + elseif isinf(size(B,1)) |
| 83 | + BM=B[1:10,1:size(B,2)] |
| 84 | + |
| 85 | + M=Matrix{Any}(undef,11,size(B,2)) |
| 86 | + for k=1:10,j=1:size(B,2) |
| 87 | + M[k,j]=BM[k,j] |
| 88 | + end |
| 89 | + for k=1:size(B,2) |
| 90 | + M[end,k]=PrintShow("⋮") |
| 91 | + end |
| 92 | + |
| 93 | + print_array(io, M) |
| 94 | + elseif isinf(size(B,2)) |
| 95 | + BM=B[1:size(B,1),1:10] |
| 96 | + |
| 97 | + M=Matrix{Any}(undef,size(B,1),11) |
| 98 | + for k=1:size(B,1),j=1:10 |
| 99 | + M[k,j]=BM[k,j] |
| 100 | + end |
| 101 | + for k=1:size(B,1) |
| 102 | + M[k,end]=PrintShow("⋯") |
| 103 | + end |
| 104 | + |
| 105 | + print_array(io, M) |
| 106 | + else |
| 107 | + print_array(io, AbstractMatrix(B)[1:size(B,1),1:size(B,2)]) |
| 108 | + end |
| 109 | + end |
| 110 | +end |
| 111 | + |
| 112 | +## Space |
| 113 | + |
| 114 | +function show(io::IO, S::PointSpace) |
| 115 | + print(io, "PointSpace(") |
| 116 | + show(io, points(S)) |
| 117 | + print(io,")") |
| 118 | +end |
| 119 | + |
| 120 | +function show(io::IO,s::QuotientSpace) |
| 121 | + show(io,s.space) |
| 122 | + print(io," /\n") |
| 123 | + show(io,s.bcs;header=false) |
| 124 | +end |
| 125 | + |
| 126 | + |
| 127 | +function show(io::IO,ss::SumSpace) |
| 128 | + s = components(ss) |
| 129 | + show(io,s[1]) |
| 130 | + for sp in s[2:end] |
| 131 | + print(io,"⊕") |
| 132 | + show(io,sp) |
| 133 | + end |
| 134 | +end |
| 135 | + |
| 136 | + |
| 137 | +function show(io::IO,ss::PiecewiseSpace) |
| 138 | + s = components(ss) |
| 139 | + show(io,s[1]) |
| 140 | + for sp in s[2:end] |
| 141 | + print(io,"⨄") |
| 142 | + show(io,sp) |
| 143 | + end |
| 144 | +end |
| 145 | + |
| 146 | +summarystr(ss::ArraySpace) = string(Base.dims2string(length.(axes(ss))), " ArraySpace") |
| 147 | +summary(io::IO, ss::ArraySpace) = print(io, summarystr(ss)) |
| 148 | +function show(io::IO,ss::ArraySpace;header::Bool=true) |
| 149 | + header && print(io,summarystr(ss)*":\n") |
| 150 | + show(io, ss.spaces) |
| 151 | +end |
| 152 | + |
| 153 | +function show(io::IO,s::TensorSpace) |
| 154 | + d = length(s.spaces) |
| 155 | + for i=1:d-1 |
| 156 | + show(io,s.spaces[i]) |
| 157 | + print(io,"⊗") |
| 158 | + end |
| 159 | + show(io,s.spaces[d]) |
| 160 | +end |
| 161 | + |
| 162 | +function show(io::IO,s::SubSpace) |
| 163 | + print(io,s.space) |
| 164 | + print(io,"|") |
| 165 | + show(io,s.indexes) |
| 166 | +end |
| 167 | + |
| 168 | +show(io::IO,::ConstantSpace{AnyDomain}) = print(io,"ConstantSpace") |
| 169 | +show(io::IO,S::ConstantSpace) = print(io,"ConstantSpace($(domain(S)))") |
| 170 | + |
| 171 | +## Segment |
| 172 | + |
| 173 | +show(io::IO,d::Segment) = print(io,"the segment [$(leftendpoint(d)),$(rightendpoint(d))]") |
0 commit comments