这段代码:
macro FL(message)
return @sprintf("%s:%d | %s", @__FILE__, @__LINE__, message) # line 2
end
println(@FL("m")) # line 4
Run Code Online (Sandbox Code Playgroud)
打印fl.jl:2 | m.我怎样才能打印出来fl.jl:4 | m?
下面的 Julia 程序在我的笔记本电脑上大约需要 6 秒(第二次测试(n))。等效的 C++ 程序(使用 Eigen)仅需 0.19 秒。根据我在https://programming-language-benchmarks.vercel.app/cpp上看到的结果,我预计差异要小得多。我的 Julia 程序出了什么问题?我将非常感谢有关如何改进我的 Julia 程序的提示。
using StaticArrays
using Printf
struct CoordinateTransformation
b1::SVector{3,Float64}
b2::SVector{3,Float64}
b3::SVector{3,Float64}
r0::SVector{3,Float64}
mf::SMatrix{3,3,Float64}
mb::SMatrix{3,3,Float64}
end
function dot(a::SVector{3,Float64}, b::SVector{3,Float64})
a[1]*b[1] + a[2]*b[2] + a[3]*b[3]
end
function CoordinateTransformation(b1::SVector{3,Float64}, b2::SVector{3,Float64}, b3::SVector{3,Float64}, r0::SVector{3,Float64})
mf = MMatrix{3,3,Float64}(undef)
e1::SVector{3, Float64} = [1.0, 0.0, 0.0]
e2::SVector{3, Float64} = [0.0, 1.0, 0.0]
e3::SVector{3, Float64} = [0.0, 0.0, 1.0]
mf[1, 1] = dot(b1, e1);
mf[1, 2] = dot(b1, e2);
mf[1, 3] = dot(b1, e3);
mf[2, …Run Code Online (Sandbox Code Playgroud)