5
5
# # which can be modified by users for other Ts
6
6
7
7
" `hasneg(::T)` attribute is true if: `pj < zero(T)` is defined."
8
- hasneg {T} (:: Type{T} ) = true
8
+ hasneg {T} (:: Type{T} ) = false
9
9
10
10
" Could value possibly be negative and if so, is it?"
11
11
isneg {T} (pj:: T ) = hasneg (T) && pj < zero (T)
@@ -20,19 +20,17 @@ showone{T}(::Type{T}) = true
20
20
# ####
21
21
22
22
# # Numbers
23
+ hasneg {T<:Real} (:: Type{T} ) = true
24
+
25
+ # ## Integer
23
26
showone {T<:Integer} (:: Type{T} ) = false
24
27
showone {T} (:: Type{Rational{T}} ) = false
25
28
26
29
27
- # # Polynomials as coefficients
28
- hasneg {S} (:: Type{Poly{S}} ) = false
29
- showoone {S} (:: Type{Poly{S}} ) = false
30
-
31
30
32
31
33
- # # Complex coefficients
34
- # # we say neg if real(z) < 0 || real(z) == 0 and imag(g) < 0
35
- hasneg {T} (:: Type{Complex{T}} ) = true
32
+ # ## Complex coefficients
33
+ hasneg {T} (:: Type{Complex{T}} ) = true # # we say neg if real(z) < 0 || real(z) == 0 and imag(g) < 0
36
34
37
35
function isneg {T} (pj:: Complex{T} )
38
36
real (pj) < 0 && return true
43
41
showone {T} (pj:: Type{Complex{T}} ) = showone (T)
44
42
45
43
44
+ # ## Polynomials as coefficients
45
+ hasneg {S} (:: Type{Poly{S}} ) = false
46
+ showone {S} (:: Type{Poly{S}} ) = false
47
+
48
+
49
+ # ####
46
50
47
51
" Show different operations depending on mimetype. `l-` is leading minus sign."
48
- function showop (:: MIME"text/html " , op)
49
- d = Dict (" *" => " × " , " +" => " + " , " -" => " - " , " l-" => " - " )
52
+ function showop (:: MIME"text/plain " , op)
53
+ d = Dict (" *" => " ⋅ " , " +" => " + " , " -" => " - " , " l-" => " - " )
50
54
d[op]
51
55
end
52
56
@@ -55,8 +59,8 @@ function showop(::MIME"text/latex", op)
55
59
d[op]
56
60
end
57
61
58
- function showop (:: MIME"text/plain " , op)
59
- d = Dict (" *" => " ⋅ " , " +" => " + " , " -" => " - " , " l-" => " - " )
62
+ function showop (:: MIME"text/html " , op)
63
+ d = Dict (" *" => " ∙ " , " +" => " + " , " -" => " - " , " l-" => " - " )
60
64
d[op]
61
65
end
62
66
77
81
78
82
function showterm {T} (io:: IO ,p:: Poly{T} ,j,first, mimetype)
79
83
pj = p[j]
84
+
80
85
pj == zero (T) && return false
81
86
82
87
pj = printsign (io, pj, j, first, mimetype)
@@ -114,7 +119,7 @@ function printcoefficient{T}(io::IO, pj::Complex{T}, j, mimetype)
114
119
115
120
if hasreal & hasimag
116
121
print (io, ' (' )
117
- showio (io, mimetype, pj)
122
+ show (io, mimetype, pj)
118
123
print (io, ' )' )
119
124
elseif hasreal
120
125
a = real (pj)
@@ -135,6 +140,7 @@ function printcoefficient{T}(io::IO, pj::T, j, mimetype)
135
140
show (io, mimetype, pj)
136
141
end
137
142
143
+ # # show exponent
138
144
function printexponent (io,var,i, mimetype:: MIME"text/latex" )
139
145
if i == 0
140
146
return
158
164
159
165
# ###
160
166
167
+ # # text/plain
161
168
@compat Base. show {T} (io:: IO , p:: Poly{T} ) = show (io, MIME (" text/plain" ), p)
162
169
@compat function Base. show {T} (io:: IO , mimetype:: MIME"text/plain" , p:: Poly{T} )
163
170
print (io," Poly(" )
166
173
167
174
end
168
175
176
+ # # text/latex
169
177
@compat function Base. show {T} (io:: IO , mimetype:: MIME"text/latex" , p:: Poly{T} )
170
178
print (io, " \$ " )
171
179
printpoly (io, p, mimetype)
179
187
@compat function Base. show {T<:Number} (io:: IO , mimetype:: MIME"text/latex" , a:: T )
180
188
print (io, a)
181
189
end
190
+
191
+
192
+ # # text/html
193
+ @compat function Base. show {T} (io:: IO , mimetype:: MIME"text/html" , p:: Poly{T} )
194
+ printpoly (io, p, mimetype)
195
+ end
196
+
197
+ @compat function Base. show {T<:Number} (io:: IO , mimetype:: MIME"text/html" , a:: T )
198
+ print (io, a)
199
+ end
0 commit comments