mirror of
https://gitlab.rlp.net/mobitar/julia_course.git
synced 2024-11-23 13:31:36 +00:00
Fix FourVector task
This commit is contained in:
parent
49096484ae
commit
c30cb07b53
1 changed files with 9 additions and 7 deletions
|
@ -1,5 +1,5 @@
|
||||||
### A Pluto.jl notebook ###
|
### A Pluto.jl notebook ###
|
||||||
# v0.18.4
|
# v0.19.0
|
||||||
|
|
||||||
using Markdown
|
using Markdown
|
||||||
using InteractiveUtils
|
using InteractiveUtils
|
||||||
|
@ -53,7 +53,7 @@ z - z'
|
||||||
|
|
||||||
$v * u = ct * ct' - x * x' - y * y' - z * z'$
|
$v * u = ct * ct' - x * x' - y * y' - z * z'$
|
||||||
|
|
||||||
$|v|^2 = ct^2 - x^2 - y^2 - z^2$
|
$|v|^2 = (ct)^2 - x^2 - y^2 - z^2$
|
||||||
|
|
||||||
You should implement $|v|^2$ as a function called `length_squared`.
|
You should implement $|v|^2$ as a function called `length_squared`.
|
||||||
"""
|
"""
|
||||||
|
@ -66,20 +66,22 @@ begin
|
||||||
|
|
||||||
# To override a predefined function of a package, the function has to be imported
|
# To override a predefined function of a package, the function has to be imported
|
||||||
# In this case, the functions are from the package `Base` which has Julia's builtin functions
|
# In this case, the functions are from the package `Base` which has Julia's builtin functions
|
||||||
import Base: +, -, *, ^
|
import Base: +, -, *, ==
|
||||||
|
|
||||||
(+)(v::FourVector, u::FourVector) = FourVector(
|
+(v::FourVector, u::FourVector) = FourVector(
|
||||||
v.ct + u.ct,
|
v.ct + u.ct,
|
||||||
v.x + u.x,
|
v.x + u.x,
|
||||||
v.y + u.y,
|
v.y + u.y,
|
||||||
v.z + u.z
|
v.z + u.z
|
||||||
)
|
)
|
||||||
|
|
||||||
#(-)(v::FourVector) = ?
|
# -(v::FourVector) = ?
|
||||||
|
|
||||||
#(-)(v::FourVector, u::FourVector) = ?
|
# -(v::FourVector, u::FourVector) = ?
|
||||||
|
|
||||||
#(*)(v::FourVector, u::FourVector) = ?
|
# *(v::FourVector, u::FourVector) = ?
|
||||||
|
|
||||||
|
# ==(v::FourVector, u::FourVector) = ?
|
||||||
end
|
end
|
||||||
|
|
||||||
# ╔═╡ 4b8da4d9-c880-405e-859e-81f5884d29bf
|
# ╔═╡ 4b8da4d9-c880-405e-859e-81f5884d29bf
|
||||||
|
|
Loading…
Reference in a new issue