当我创建一些数组A并将其分配给B时
A = [1:10]
B = A
Run Code Online (Sandbox Code Playgroud)
我可以修改A,更改反映在B中
A[1] = 42
# B[1] is now 42
Run Code Online (Sandbox Code Playgroud)
但是,如果我使用标量变量执行此操作,则更改不会传播:
a = 1
b = a
a = 2
# b remains being 1
Run Code Online (Sandbox Code Playgroud)
我甚至可以将事物混合起来并将矢量转换为标量,并且变化不会传播:
A = [1:10]
B = A
A = 0
# B remains being 1,2,...,10
Run Code Online (Sandbox Code Playgroud)
=运营商究竟做了什么?当我要复制的变量和修改旧的保存新变量的完整性,当我应该使用b = copy(a)经过短短b=a?
假设我创建了这个简单的字符串宏
macro e_str(s)
return string("I touched this: ",s)
end
Run Code Online (Sandbox Code Playgroud)
如果我将它应用于带插值的字符串,我会得到:
julia> e"foobar $(log(2))"
"I touched this: foobar \$(log(2))"
Run Code Online (Sandbox Code Playgroud)
而我想获得:
julia> e"foobar $(log(2))"
"I touched this: foobar 0.6931471805599453"
Run Code Online (Sandbox Code Playgroud)
我必须对我的宏声明做出哪些更改?
我想在gnuplot中重现这个效果:

我怎么能得到它?如果无法完成,我可以用什么软件来重现它?
我正在寻找朱莉娅中的某些东西,比如理解但是对于矩阵而不是向量.如果我有一些单变量函数f(x),我想那是充满了一个数组f(i)的i中1..10,我可以这样做:
[f(i) for i = 1:10]
Run Code Online (Sandbox Code Playgroud)
如果我有一些双变量函数g(i,j),我想要一个i=[1,10]; j=[1,10]填充函数的矩阵,我可以这样做:
M = zeros (10,10)
for i in 1:10
for j in 1:10
M[i,j] = g(i,j)
end
end
Run Code Online (Sandbox Code Playgroud)
是否有一些快捷方式允许我以较短的方式表达它而不浪费时间分配所有的零?
我在朱莉娅写了一个直接的例行程序,可移植性问题让我在C中重写它.写完之后,我对加速感到惊讶,我期待甚至一个数量级但不是两个!
我想知道这种加速是否正常只有C中的重写,因为Julia如此专注于速度和HPC.
这是代码,我简化了它们,使它们简洁,保留了C的加速(所有质量都是1,力就是两个物体的距离).
循环迭代每个索引(星形属性数组是固定大小,但我只使用前400个进行测试)并计算其余索引的贡献,然后使用Euler积分器计算新位置(新速度) + = F/m乘以dt,新位置+ =速度乘以dt).
用C编译gcc并且没有特殊标志的C代码time ./a.out给出0.98s:
#include <stdio.h>
#include <stdlib.h>
// Array of stars is fixed size. It's initialized to a maximum size
// and only the needed portion it's used.
#define MAX_STAR_N (int)5e5
double *x,*y,*z,*vx,*vy,*vz;
void evolve_bruteforce(double dt){
// Compute forces and integrate the system with an Euler
int i,j;
for(i=0;i<400;i++){
double cacheforce[3] = {0,0,0};
double thisforce[3];
for(j=0;j<400;j++){
if(i!=j){
thisforce[0] = (x[j] - x[i]);
thisforce[1] = (y[j] - y[i]);
thisforce[2] = …Run Code Online (Sandbox Code Playgroud) 我正在使用 emacsorg-mode排版注释并通过 LaTeX 将它们导出为 pdf。一切正常,除非我使用 Unicode 符号,例如
\begin{equation}
\left( \frac{P^2}{2m} + V(x,y,z) \right) ? = E ?
\end{equation}
Run Code Online (Sandbox Code Playgroud)
我在哪里使用?. 使用#+latex_compiler: lualatex和
(setq org-latex-pdf-process
'("lualatex -shell-escape -interaction nonstopmode %f"
"lualatex -shell-escape -interaction nonstopmode %f"))
Run Code Online (Sandbox Code Playgroud)
我已经设法使用 LuaLaTeX 将或多或少的问题导出到 PDF,但是C-c C-x C-l对于带有 Unicode 符号的公式()的预览完全中断。
我需要在我的 emacs 配置中进行哪些更改才能将 LuaLaTeX 用于与 LaTeX 相关的所有内容org-mode?