我正在尝试为二项式系数生成一个函数。我正在为此使用 nCk=n!/(k!(nk)!) 公式。
我目前的代码是:
function factorial {
typeset n=$1
(( n < 2 )) && echo 1 && return
echo $(( n * $(factorial $((n-1))) ))
}
function nCk {
echo $((factorial $1/$(( factorial $2 *factorial $(($1-$2)) )) ))
}
Run Code Online (Sandbox Code Playgroud)
但是我遇到了错误,因为我可能会弄乱语法。
当我尝试使用gvim <filename>命令打开文件时,我看到一个闪烁或闪烁的窗口
.
我不确定这是否与Mac OS有关.我已经安装了macvim brew(如何在OS X上安装MacVim?).
虽然存在类似的帖子,但请不要标记这篇文章:VIM闪烁问题,因为问题无法通过遵循答案得到解决(最多投票的答案提到链接断开的屏幕截图).
我正在使用最新的macOS Mojave(10.14).
我编写了以下最小的 Python 代码,以便x在同一 X 轴上绘制各种函数。
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
from cycler import cycler
cycle = plt.rcParams['axes.prop_cycle'].by_key()['color']
xlabel='$X$'; ylabel='$Y$'
### Set tick features
plt.tick_params(axis='both',which='major',width=2,length=10,labelsize=18)
plt.tick_params(axis='both',which='minor',width=2,length=5)
#plt.set_axis_bgcolor('grey') # Doesn't work if I uncomment!
lines = ["-","--","-.",":"]
Nlayer=4
f, axarr = plt.subplots(Nlayer, sharex=True)
for a in range(1,Nlayer+1):
X = np.linspace(0,10,100)
Y = X**a
index = a-1 + np.int((a-1)/Nlayer)
axarr[a-1].plot(X, Y, linewidth=2.0+index, color=cycle[a], linestyle = lines[index], label='Layer = {}'.format(a))
axarr[a-1].legend(loc='upper right', prop={'size':6})
#plt.legend()
# …Run Code Online (Sandbox Code Playgroud) 我有以下 Matlab 代码,我想将其转换为 Python 3 代码。
r = (0:1:15)'; % create a matrix of complex inputs
theta = pi*(-2:0.05:2);
z = r*exp(1i*theta);
%w = z.^(1/2) ; % calculate the complex outputs
w = sqrt(r)*exp(1i*theta/2);
figure('Name','Graphique complexe','units','normalized','outerposition',[ 0.08 0.1 0.8 0.55]);
subplot(121)
surf(real(z),imag(z),real(w),imag(w)) % visualize the complex function using surf
xlabel('Real(z)')
ylabel('Imag(z)')
zlabel('Real(u)')
cb = colorbar;
colormap jet; % gradient from blue to red
cb.Label.String = 'Imag(v)';
subplot(122)
surf(real(z),imag(z),imag(w),real(w)) % visualize the complex function using surf
xlabel('Real(z)')
ylabel('Imag(z)')
zlabel('Imag(v)')
cb = …Run Code Online (Sandbox Code Playgroud) matplotlib ×2
python ×2
3d ×1
bash ×1
combinations ×1
factorial ×1
function ×1
macos ×1
macos-mojave ×1
macvim ×1
matlab ×1
python-3.x ×1
shell ×1
vim ×1