File tree Expand file tree Collapse file tree 6 files changed +22
-98
lines changed
Expand file tree Collapse file tree 6 files changed +22
-98
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,12 @@ Number >> asComplex [
1515
1616{ #category : #' *Math-Complex' }
1717Number >> complexConjugate [
18- ^ self .
18+ " The complex conjugate of a complex number (a + bi) is another complex number (a - bi).
19+ Every real number x is also a complex number with imaginary part equal to 0.
20+ In other words, x = x + 0i and x = x - 0i.
21+ Therefore, the complex conjugate of a real number is the same real number"
22+
23+ ^ self
1924]
2025
2126{ #category : #' *Math-Complex' }
@@ -37,13 +42,11 @@ Number >> i: aNumber [
3742{ #category : #' *Math-Complex' }
3843Number >> isComplexConjugateOf: aNumber [
3944 " A complex conjugate of a real number is same real number"
40- ^ self = aNumber
41- ]
45+ self
46+ deprecated: ' This method is redundant. Just check the equality with complexConjugate'
47+ transformWith: ' `@rec isComplexConjugate: `@arg' - > ' `@rec complexConjugate = `@arg' .
4248
43- { #category : #' *Math-Complex' }
44- Number >> isComplexConjugateOfAComplexNumber: aComplexNumber [
45- " A complex conjugate of a real number is same real number"
46- ^ self isComplexConjugateOf: aComplexNumber
49+ ^ self complexConjugate = aNumber
4750]
4851
4952{ #category : #' *Math-Complex' }
Original file line number Diff line number Diff line change @@ -537,13 +537,11 @@ PMComplex >> imaginary [
537537{ #category : #testing }
538538PMComplex >> isComplexConjugateOf: aNumber [
539539 " Answer true if self and aNumber are complex conjugates of each other. The complex conjugate of a complex number is the number with an equal real part and an imaginary part equal in magnitude but opposite in sign."
540- ^ aNumber isComplexConjugateOfAComplexNumber: self
541- ]
540+ self
541+ deprecated: ' This method is redundant. Just check the equality with complexConjugate'
542+ transformWith: ' `@rec isComplexConjugate: `@arg' - > ' `@rec complexConjugate = `@arg' .
542543
543- { #category : #testing }
544- PMComplex >> isComplexConjugateOfAComplexNumber: aComplexNumber [
545- " Answer true if self and aComplexNumber are complex conjugates of each other. The complex conjugate of a complex number is the number with an equal real part and an imaginary part equal in magnitude but opposite in sign."
546- ^ (aComplexNumber real = real) and : [ aComplexNumber imaginary = (- 1 * imaginary) ]
544+ ^ self complexConjugate = aNumber
547545]
548546
549547{ #category : #testing }
Original file line number Diff line number Diff line change @@ -567,7 +567,7 @@ PMMatrix >> isHermitian [
567567
568568 1 to: self numberOfRows do: [ :i |
569569 1 to: (i - 1 ) do: [ :j |
570- ((self at: i at: j) isComplexConjugateOf: (self at: j at: i))
570+ ((self at: i at: j) complexConjugate = (self at: j at: i))
571571 ifFalse: [ ^ false ] ] ].
572572
573573 ^ true
Original file line number Diff line number Diff line change 1+ Extension { #name : #NumberTest }
2+
3+ { #category : #' *Math-Tests-Complex' }
4+ NumberTest >> testComplexConjugate [
5+
6+ self assert: 5 complexConjugate equals: 5
7+ ]
Original file line number Diff line number Diff line change @@ -384,60 +384,6 @@ PMComplexTest >> testHash [
384384 self assert: aComplex copy hash equals: aComplex hash
385385]
386386
387- { #category : #tests }
388- PMComplexTest >> testIsComplexConjugateOfConjugateComplex [
389-
390- self assert: ((3 + 2i) isComplexConjugateOf: (3 - 2i))
391- ]
392-
393- { #category : #tests }
394- PMComplexTest >> testIsComplexConjugateOfConjugateComplexAndReal [
395-
396- self assert: ((5 + 0i) isComplexConjugateOf: 5 )
397- ]
398-
399- { #category : #tests }
400- PMComplexTest >> testIsComplexConjugateOfConjugateRealAndComplex [
401-
402- self assert: (5 isComplexConjugateOf: (5 - 0i))
403- ]
404-
405- { #category : #tests }
406- PMComplexTest >> testIsComplexConjugateOfDifferentReal [
407-
408- self deny: (- 5 isComplexConjugateOf: 5 )
409- ]
410-
411- { #category : #tests }
412- PMComplexTest >> testIsComplexConjugateOfNonConjugateComplexAndReal [
413-
414- self deny: ((5 + 3i) isComplexConjugateOf: 5 )
415- ]
416-
417- { #category : #tests }
418- PMComplexTest >> testIsComplexConjugateOfNonConjugateDifferentComplex [
419-
420- self deny: ((- 0.5 - 1i) isComplexConjugateOf: (3 - 2i))
421- ]
422-
423- { #category : #tests }
424- PMComplexTest >> testIsComplexConjugateOfNonConjugateRealAndComplex [
425-
426- self deny: (5 isComplexConjugateOf: (5 - 3i))
427- ]
428-
429- { #category : #tests }
430- PMComplexTest >> testIsComplexConjugateOfSameComplex [
431-
432- self deny: ((3 - 2i) isComplexConjugateOf: (3 - 2i))
433- ]
434-
435- { #category : #tests }
436- PMComplexTest >> testIsComplexConjugateOfSameReal [
437-
438- self assert: (5 isComplexConjugateOf: 5 )
439- ]
440-
441387{ #category : #tests }
442388PMComplexTest >> testIsComplexNumberOnComplex [
443389
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments