vector calculation in numpy


# show vector calculation in numpy function

import numpy as np

# new vec
vec_1 = np.array([1,1,0])
vec_2 = np.array([2,3,1])

# mode of the vec
vec_mode = np.linalg.norm(vec_1)

# dot:a.b=|a|*|b|*cos(theta)
vec_dot = np.dot(vec_1, vec_2)

# cross: a*b = c, |a*b|=|a|*|b|*sin(theta)
vec_cross = np.cross(vec_1, vec_2)

print(' mode for vev_1:', vec_mode, '\n dot:', vec_dot, '\n cross:', vec_cross)

在 Ubuntu 20.04 LTS 桌面版上安装 MS 字体

使用命令行安装

  1. $ sudo apt update
  2. $ sudo apt install ttf-mscorefonts-installer
  3. $ sudo fc-cache -f -v

将所有的 Windows 字体复制到 /usr/share/fonts 目录下并使用一下命令安装字体:

  1. $ mkdir /usr/share/fonts/WindowsFonts
  2. $ cp /Windowsdrive/Windows/Fonts/* /usr/share/fonts/WindowsFonts
  3. $ chmod 755 /usr/share/fonts/WindowsFonts/*
  4. fc-cache

photoshop loadlibrary failed with error 87

Windows 10上运行photoshop、nextcloud等软件的时候出现错误提示“loadlibrary failed with error 87”,网上有很多同样的错误,总结如下:

1、此问题从Windows 8就开始出现了,发生问题的软件都是 CAD、PS 之类,其实是AMD显卡的问题,将驱动恢复到2013年之前即可。
2、简单粗暴有效的一个方法是进入C:\Windows\System32 ,搜索atig6pxx.dll 全部删除,为了以防万一,请提前备份。
注意:在删除文件时,可能会提示你需要管理员权限。这时,点击“继续”即可。
3、删除完毕问题解决,可重启软件,不再出现错误提示。

Matplotlib 001


import matplotlib.pyplot as plt
import numpy as np
import csv
column1=[]
column2=[]
with open('book1.csv','r',encoding='utf-8') as data_input:
reader= csv.reader(data_input)
for row in reader:
try:
data1=float(row[0])
data2=float(row[1])
column1.append(data1)
column2.append(data2)
except ValueError:
continue
'''
x=np.linspace(0,10,100)
y=np.sin(x)
y1=np.random.randn(100)
plt.scatter(x,y1,label="scatter figure")
'''
plt.plot(column1,column2,ls='-',lw=2,label="plot figure")
plt.legend()
#plt.xlim(0,10)
#plt.ylim(0,1)
plt.xlabel("x axis")
plt.ylabel("y axis")
#plt.axhline(y=0.5,ls='--')
plt.show()