0%

当前章节:向量数据库
目录导航

介绍

向量数据库是实现本地知识库的必备数据库。传统数据库是一种面向业务的数据库类型,不适用存储向量,以及快速相似查找。我们将文本分割后,通过text2vec模型将文本转为向量存储,与问题的向量比较相似度,最后选出topk实现信息匹配查找。

原理

向量数据库最重要的两点就是向量存储和最大相似度查找,一般向量数据库会使用KNN来实现最近邻的向量查找。

现有数据库

  1. annoy:小型数据库,仅CPU,1M条向量建树10min+,查找需要10ms级时间,响应较快
  2. faiss:支持GPU加速,数据量越大,性能越优,支持批量插入和查询
  3. milvus:不仅仅向量查询,提供了完整的数据库的业务支持,开源,建议大型项目使用。

测试

总结

项目测试时可以使用annoy数据库测试,在实际配置时可以为多个数据库实现接口。

原文链接:c++快速进阶-持续更新

  1. 构造
  2. 析构
  3. 继承
  4. 派生

多继承问题

当多继承类有共同基类时,基类会构造多次,为了消除基类的二义性,我们采用虚继承方式。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include<iostream>


class A{
public:
A(){
std::cout<<"A create\n";
}



~A(){
std::cout<<"A delete\n";
}
};

class B:virtual public A{
public:
B():A(){
std::cout<<"B create\n";
}




~B(){
std::cout<<"B delete\n";
}
};


class C:virtual public A{
public:
C():A(){
std::cout<<"C create\n";
}
~C(){
std::cout<<"C delete\n";
}
};


class D:public B,C {
public:
D():B(),C(){
std::cout<<"D create\n";
}

};


int main(){

D d=D();

std::cin.get();
return 0;
}


虚函数:

基类的派生类是一个具有多个类特性的单类,在赋值时可以互相赋值。
类编译时是静态编译,若A-B-C依次派生,A指针赋值BC,调用的函数实际上还是A的函数。
实现编译器能识别,可以将需要的函数标记virtual,同时各派生类使用override重写(防止函数名写错无效重写),实现动态编译

纯虚函数

接口类声明一个未定义函数,该函数需要被子类实现,否则无法实例化,是一个抽象类。

虚函数不需要重写,但纯虚函数要求

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include<iostream>


class A{
public:
A(){
std::cout<<"A create\n";
}

void print(){
std::cout<<"A print\n";
}
virtual void virtualprint(){
std::cout<<"A virtualprint\n";
}

virtual void interface()=0;

~A(){
std::cout<<"A delete\n";
}
};

class B:virtual public A{
public:
B():A(){
std::cout<<"B create\n";
}

void print(){
std::cout<<"B print\n";
}
void virtualprint() override{
std::cout<<"B virtualprint\n";
}
void interface() override{
std::cout<<"B interface override\n";
}

~B(){
std::cout<<"B delete\n";
}
};


int main(){

B b=B();
A* a=&b;
a->print();
a->virtualprint();
a->interface();
std::cin.get();
return 0;
}

可见性:

pri:仅类内 pro:仅派生类内 pub:全

友元:
friend关键字,标记函数,类,类成员函数,在不破坏可见性条件下操作类内私有对象

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include<iostream>

class B;
class A{

friend void get_private_a(A const &a);
friend class B;
private:
int a;
public:
A(int a):a(a){
std::cout<<"A create:"<<a<<"\n";
}
~A(){
std::cout<<"A delete\n";
}
};

class B:virtual public A{
public:
B(int a):A(a){
std::cout<<"B create:"<<a<<"\n";
}
void get_private_a(A const &a) {
std::cout<<"A.a:"<<a.a<<"\n";
}
~B(){
std::cout<<"B delete\n";
}
};

void get_private_a(A const &a) {
std::cout<<"A.a:"<<a.a<<"\n";
}


int main(){

A a=A(2);
B b=B(0);
get_private_a(a);
b.get_private_a(a);
std::cin.get();
return 0;
}

常量特性

  1. 作用范围
    const int* a/ int const* a:
    a不能修改(指针指向内容不能修改),可以重新赋值指针
    int
    const a:
    a本身不能修改,*a可以修改

  2. 常量限制
    const修饰成员函数表明这个函数不会修改类内成员变量。
    const 对象只能调用const成员函数,这保证了限制的完备性,变量不会有任何变化。

  3. 多个函数
    const可以区分同名函数,但不能区分构造函数

  4. 突破限制
    标记mutable标记的变量可以被const修改

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    class A{
    private:
    int a;
    const int b;
    mutable int c;

    public:
    A(int a):a(a){
    std::cout<<"A create:"<<a<<"\n";
    }
    void seta(int a){
    this->a=a;
    }
    // void seta(int a) const{
    // this->a=a;
    // }
    // void setb(int b){
    // this->b=b;
    // }
    void setc(int c) const{
    this->c=c;
    }

    ~A(){
    std::cout<<"A delete\n";
    }
    };

初始列表

在构造函数时使用构造列表实例化对象。在cpp的类中,classA a作为一个成员变量,在构造函数被赋值a=classA(0),如果存在classA()缺省构造,则A会构造2次,构造列表能避免

三元操作符

a= cond1?cond2:1:2 可嵌套

构造实例

构造空间

栈:classA a;==classA a=classA();
堆:new delete malloc free

构造实例类型

explicit 作用于构造函数,不允许隐式类型转换

运算符重载

operator++/–/+/-/==/!= 运算符重载

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include<iostream>

class Coordinate2D{
private:
int x;
int y;
public:
Coordinate2D(int x,int y):x(x),y(y){
std::cout<<"Coordinate2D create:"<<x<<','<<y<<"\n";
}
Coordinate2D operator+(const Coordinate2D& other){
return Coordinate2D(this->x+other.x,this->y+other.y);
}
Coordinate2D operator-(const Coordinate2D& other){
return Coordinate2D(this->x-other.x,this->y-other.y);
}
Coordinate2D& operator++(){
x++;
y++;
return *this;
}
Coordinate2D operator++(int){
Coordinate2D old=*this;
x++;
y++;
return old;
}
friend std::ostream& operator<<(std::ostream& os,const Coordinate2D& cod){
os<<"("<<cod.x<<','<<cod.y<<')'<<'\n';
return os;
}
// cin overloading is weak
// friend std::istream& operator>>(std::istream& is,Coordinate2D& cod){
// is >>cod.x;
// return is;
// }

~Coordinate2D(){
std::cout<<*this<<" delete\n";
}
};


int main(){
Coordinate2D o=Coordinate2D(0,0);
Coordinate2D a=Coordinate2D(1,0);
Coordinate2D b=Coordinate2D(0,-1);
Coordinate2D c=a+(++b);
std::cout<<'c'<<c;
std::cout<<'a'<<a;

std::cin.get();
return 0;
}



this

this就是类的当前实例的指针,this是否可修改取决于当前函数是否const

智能指针

memory库的unique_ptr
特性:

  1. 该指针只能存在一个,不能同时存在两个指向同一个对象的指针
  2. 使用make unique 安全构造
  3. 使用move指令移动
    1
    2
    std::unique_ptr<Coordinate2D> p=std::make_unique<Coordinate2D>(1,2);
    std::unique_ptr<Coordinate2D> p2=std::move(p);
    shared ptr:使用引用计数控制对象
    weak ptr:shared的弱引用
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
{
std::unique_ptr<Coordinate2D> p1=std::make_unique<Coordinate2D>(1,0);
std::unique_ptr<Coordinate2D> p2=std::move(p1);
}

std::shared_ptr<Coordinate2D> p2;
{
std::shared_ptr<Coordinate2D> p1=std::make_unique<Coordinate2D>(2,0);
p2=p1;
}

std::weak_ptr<Coordinate2D> p4;
{
std::shared_ptr<Coordinate2D> p3=std::make_unique<Coordinate2D>(3,0);
p4=p3;
}

copy构造

将一个函数=delete,表示不允许拷贝构造

  1. 使用等于复制对象时,c++实际上是调用了复制构造函数,默认的是shallow copy,当对象的成员是指针时,这会导致两个实例指向了同一个堆中的对象,在析构删除实例的时候,会删除堆两次。
  2. 实现复制构造很重要
  3. 在函数传参时,尽量使用const reference,速度快,保证只读性,如果直接是类参数,每次函数栈都要复制删除一次
1
2
3
4
Coordinate2D(const Coordinate2D& cpy)=delete;
Coordinate2D(const Coordinate2D& cpy){
Coordinate2D(cpy.x,cpy.y);
}

stl

https://zhuanlan.zhihu.com/p/564057584

vector

动态数组,连续对象优于连续指针,保证内存访问局部性

使用push问题:

  1. push入对象每次都要从当前域将对象复制到vector空间中
  2. 每次vector变化都要重新复制所有数据
    这会导致指数式变化

解决:

  1. 使用emplace_back替代push,直接让vector创建对象
  2. reverse指定初始数组大小
1
2
3
4
5
6
std::vector<Coordinate2D> vcod;
vcod.reserve(3); // reduce duplicate malloc memory
// vcod.push_back({0,0}); create on stack and cpy to vec
vcod.emplace_back(0,0); //send args to vec to create
vcod.emplace_back(1,0);
vcod.emplace_back(2,0);

array

array<type,size>,相比于c语言数组,array底层是宏和模板实现的,无性能开销,且提升代码安全和维护性

std::array<Coordinate2D,3> codarr{Coordinate2D(0,0),Coordinate2D(0,0),Coordinate2D(0,0)};

list

set map

unordered_set,unordered_map

链接

详见linux开发中的gcc编译

多值传参

  1. 定义结构体返回
  2. 直接参数指针
  3. 返回数组,tuple,pair或其他的

template

  1. 函数使用template实现函数模板
  2. 类使用template实现成员变量模板化
    1
    2
    3
    4
    5
    template<typename T>
    bool equal(const T& a1,const T& a2){
    return a1==a2;
    }
    std::cout<<equal<int>(1,2);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
template<int N,class type>
class Arr{
private:
int size=N;
type arr[N];
public:
Arr(){
for(int i=0;i++;i<size) arr[i]=0;
}
Arr(type x){

for(int i=0;i<size;i++) arr[i]=x;
}
void print(){
for(int i=0;i<size;i++){
std::cout<<i<<":"<<arr[i]<<'\n';
}
}
};
Arr<10,float> a(1.1);

auto

两面性:auto能够兼容API返回类型变化,但要保证auto变量的抽象性不被破坏

主要在数组迭代器中缩略变量的类型如std::vectorstd::string

函数指针,lambda与回调函数

函数指针是实现函数作为变量的方法
void(*func)(params)=funca;
func(actual params);

为了简化奇怪的函数定义,我们使用typedef
typedef void(*func)(params)
func f=funca;

例如有个函数是遍历vector中对象,并实现一个print操作,这个函数传入vector加一个函数指针,实现指定操作。当传入不同函数指针实现不同操作,从而达到实现回调函数的目的。

为了进一步提升效率,回调函数可能非常多以至于不需要每次都将函数定义出来,直接使用lambda函数实现

[capture](arg){body}

如果lambda复杂,需要使用本地参数,需要指定capture,如=表示直接拷贝所有值,&或直接指定变量,还可以标记mutable修改对象值

当然,由于使用了捕获,需要使用functional库
std::function<void(int)>& f 来支持这种函数指针

回调函数通过函数指针实现传输,可以通过这种方式实现多任务分布式系统下的异步执行。例如点击一个按钮1s后恢复,不需要一直等待只需要传入恢复函数,按钮等待完毕后直接调用恢复。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include<iostream>
#include<String>
void callback(const std::string& msg){
std::cout<<"delay callback:"<<msg;
};

typedef void(*func_ptr)(const std::string&);

void callprocess(func_ptr& func){
std::cout<<"processing...:";
func("callprocess calling callback function\n");
}


int main(){

// 1. using function pointer directly;
void(*func)(const std::string&)=callback;
func("direct function pointer\n");


// 2. using typedef define func_pter type;
func_ptr funcp=&callback;
callprocess(func);

// 3. using lambda func defined in function.
func_ptr lambda_func=[](const std::string& msg){std::cout<<"labmda function:"<<msg;};
callprocess(lambda_func);

std::cin.get();
return 0;
}


命名空间

using namespace 看上去简单,实际上难降低代码阅读性,cpp标准库命名蛇形,我们自定义函数可以使用帕斯卡,实现快速辨别

using类似import,会出现函数重名的现象,通过namespace a{}构建命名空间

时间库

chrono时间库:c++标准时间库
包括time_point duration clock 主要3个类。

需要原因:

  1. 显示时间
  2. 存在规划
  3. 通信同步的需求

解决:
获取系统时间变量并转为时间戳,然后转为localtime获取各时间或者直接使用strftime。
对于时间间隔可以使用时间戳差值进行比较。
线程挂起定义一个duration变量然后使用当前线程的sleep_for函数

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
void time_tick(){
using namespace std::chrono;
std::chrono::system_clock::time_point t1=std::chrono::system_clock::now();
time_t timestamp=system_clock::to_time_t(t1);

std::tm* t3=std::localtime(&timestamp);
char tbuf[80];
std::strftime(tbuf,sizeof(tbuf),"%Y-%m-%d-%H-%M-%S",t3);
std::cout<<"strftime:"<<tbuf<<"\n";
}



int main(){


using namespace std::chrono;

// 1. time point

std::chrono::system_clock::time_point t1=std::chrono::system_clock::now();

time_t timestamp=system_clock::to_time_t(t1);

std::cout<<"timestamp:"<<timestamp<<"\n";

std::tm* t3=std::localtime(&timestamp);
std::cout<<"t3:"<<t3<<"\n";


char tbuf[80];
std::strftime(tbuf,sizeof(tbuf),"%Y-%m-%d-%H-%M-%S",t3);
std::cout<<"strftime:"<<tbuf<<"\n";

std::cout<<"d:"<<t3->tm_mday<<" m:"<<t3->tm_mon+1<<" y:"<<t3->tm_year+1900<<" day in year:"<<t3->tm_yday<<"\n";

duration<int,std::ratio<1>> dur(2); //1s
std::this_thread::sleep_for(dur);
time_tick();


std::cin.get();
return 0;
}

chrono库实现时序计时
要适当挂起保证任务不一直占用
literal的chrono literal空间的sleep实现

io复用与io阻塞

IO复用主要是在linux下实现网络通信的连接管理。

阻塞
BIO阻塞型,当系统调用读写时,系统未准备好时阻塞
NIO非阻塞,立即返回,通过轮询处理

复用
场景:网络通信中,程序需要读写数据,但如果使用阻塞io会导致整个程序会被单个io阻塞,导致可能数据读写不能立即响应。例如服务器与所有客户端通信,每个客户端维护一个fd,我们需要一个方法能够去处理存在事件的fd。
解决:select Poll epoll
思想:使用位图bitmap实现,服务器进程初始化一个位图,这个位图对应所有io,我们将这个位图交给内核去处理,当有事件时,对应fd会置位,我们遍历所有fd然后去读取或处理被置位的io即可
select:当没有事件时内核会一直阻塞,直到有事件,且bitmap每次都需要置位
poll:不会阻塞
epoll:不会阻塞,且会讲有事件的fd前置,只需要遍历前面的fd即可

多线程

thread库

  1. linux系统中gcc的thread库基于pthread实现,可以直接使用。并且linux系统库使用c实现的多进程线程与通信更安全可靠
  2. win下使用mingw的gcc编译会无法使用thread库,需要如下操作:
    1. 下载https://gitcode.com/mirrors/meganz/mingw-std-threads/tree/master项目下的thead相关的.h文件
    2. 将其放置到gcc的lib库中c++部分,如C:\gcc\mingw64\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++
      3.使用#include<mingw.thread.h>
      如下文件:
      mingw.condition_variable.h
      mingw.future.h
      mingw.invoke.h
      mingw.latch.h
      mingw.mutex.h
      mingw.shared_mutex.h
      mingw.thread.h

除非在win下有应用需求否在不建议使用c++的线程库

算法

字符串
数组
线性表
树:深度遍历和层次遍历
图:广度遍历
区间,矩阵,字典树

双指针,滑动窗口,哈希表,二分查找
递归,回溯,分治,堆(优先队列)
动态规划

unordered_set,unordered_map
min,max
swap
queue dequeue stack priority_queue:greater创建小堆
initializer_list
decltype
lower_bound
fabs
asm

项目

目前计划准备2两个:C++开发项目和一个unity项目

要了解的库有 json,linux内核库,muduo
要了解的工具 cmake,redis

多线程网络项目

unity2.5D项目

高等数学

中值定理

  1. 费马引理(由该定理依次证明2.3.4)
  2. 罗尔定理
  3. 拉格朗日定理
  4. 柯西中值定理

重点思考方向:

  1. 极限保号性(在端点处出现极限时使用)
  2. 构造函数(当出现证明存在ξ成立的等式):一般xf(x),以及与e^x的函数

多元函数极限

https://zhuanlan.zhihu.com/p/98921951

多元函数极限不同于一元极限,多个变量由于维度增加,极限的移动路径不唯一,因此洛必达、等价无穷小的适用范围大大缩小,该类题型一般不会出使用一般方法求解的题。

常用方法:

  1. 有理化
  2. 放缩
  3. 极限定义
  4. 夹逼准则

放缩

放缩公式https://zhuanlan.zhihu.com/p/396423540

常用放缩不等式:

  1. $sinx<x<tanx \quad [x\in (0,\pi/2)]$
  2. $x/(1+x)<ln(x+1)<x\quad [x\in (0,+\infty)]$
  3. $x<x+1<e^x\quad [x\in (0,+\infty)]$
  4. $x^2+y^2 \geq 2xy$
  5. $|x-y|\geq x-y$
  6. $泰勒放缩$

多元函数微分

2012数一.3
2016数一.4
2020数一.2

雅可比矩阵 jacobian matrix

在线性空间中定义的积分,需要通过换元简化积分计算,
在换元时微分需要雅可比矩阵实现线性映射
例题24-660-114

积分因子法 integrating factor

对于隐函数求原函数可以通过构造积分因子让可表示为全微分形式,简化求解

微分方程

https://zhuanlan.zhihu.com/p/580375148?utm_id=0

一阶:

  1. 一阶线性微分方程-公式
  2. 可分离-分离
  3. y/x型-y/x换元
  4. 伯努利微分方程-将Q(x)x^α除过去再换元后变成1阶线性,通过公式求解

高阶:

  1. y’’=f(x)-可直接换元降解型
  2. y’’=f(x,y)- y’换元u
  3. y’’=f(y’,y)-y’换元u,y’’=du/dy*u

高级常系数齐次:特征方程求解通解

高级常系数非齐次:齐次通解+特解

高阶微分方程性质:

  1. 非齐次特解差为齐次通解
  2. 齐次通解+非齐次特解=非齐次通解

欧拉方程:通过换元求解
https://zhuanlan.zhihu.com/p/444842746

微分物理应用

数一早期0几年前常考,近10年基本不考
主要是微分定义的考察,通过构建一个微分等式求解,本质是微分方程求解。

积分几何应用

主要为平面和空间积分

平面积分

平面主要是二重积分计算

空间积分

  • 曲线积分:

    1. Ⅰ型曲线:封闭-使用曲线的方向余弦(单位方向向量)转为Ⅱ型,不封闭-直接利用投影转换到单个维度计算积分。
    2. Ⅱ型曲线:封闭曲线-斯托克斯公式+方向余弦转Ⅰ型曲面积分。不封闭-直接分维度计算或转Ⅰ型
  • 曲面积分:

    1. Ⅰ型曲面:转为投影面的平面积分
    2. Ⅱ型曲面:封闭-高斯公式转三重积分。不封闭-补面高斯或利用方向余弦转Ⅰ型曲面计算。
  • 方向余弦:单位的曲面法向量或曲线方向向量
  • 斯托克斯公式利用方向余弦转为Ⅰ型曲面无方向
  • 斯托克斯公式与rot旋度算子公式类似
  • 坐标变换中不规则圆可以先线性变换后再极坐标变换
  • $x^{2/3}+y^{2/3}=1$面积计算
    格林公式无定义点2021.20

级数收敛、和函数计算

真题背景:
收敛的证明除了简单形式的级数和数列可以通过一般方法直接证明,其它都需要结合题目条件。
对于数一题目,必然是无法直接一般方法证明。
如21(18),20(17),19(18),18(19),16(19),且22,23未考,24概率极大。
并且级数的重点由单一收敛证明、计算和函数转向为求收敛域、复杂通项的计算

收敛常用思想:

  1. 放缩:利用基本不等式放缩;利用条件放缩;
  2. 20(17)求导?19(18)换元?18(19)中值定理?16(19)跨度?

主要利用条件,结合条件形式考虑方法,不能快速找到->立即放弃

无穷级数

初级 https://zhuanlan.zhihu.com/p/638303774?utm_id=0

深入 https://zhuanlan.zhihu.com/p/113428001?utm_id=0

(2016数一.19)

级数敛散性

比值-根值-比较法极限形式-比较法-定义法

  • P级数通过积分审敛法证明
  • 广义P积分 $1/{n^bln^an}$,当a<1时任意b都发散,a=1时,b>1收敛,b<=1发散

线性代数

矩阵相似

线性方程组的解与空间平面位置关系

三个平面位置可能性

平面的一般方程ax+by+cz=d,(a,b,c)为法向量,法向量组成系数矩阵A,三个方程组成增广矩阵A’,假设有三个平面,那么平面的可能性有图中8种。

A的秩表示三个法向量的关系,A’的秩和A秩的关系表示解的类型

RA和RA’有9种情况,其中由于增广阵只与A多一列,秩最多+1,并且RA’>RA,

RA RA’ 类型 说明
1 1 7 三个法向量成比例,且三个平面存在公共解,秩相等
1 2 1,4 三个法向量成比例,且三个平面无公共解,秩不相等
2 2 6,8 存在一个向量与三个法向量内积为0,即存在齐次解,且三个平面存在公共解,秩相等
2 3 2,3 存在一个向量与三个法向量内积为0,即存在齐次解,且三个平面无公共解,秩不相等
3 3 5 三个法向量无解,且且三个平面存在一个交点,秩相等

矩阵相似判定条件

定义:$$\exist P可逆,有 P^{-1}AP=B \leftrightarrow A\sim B$$

充要条件:

  1. 定义
  2. $$\forall \mu,有\mu E-A \sim \mu E-B$$
  3. $$特征矩阵 \lambda E-A \cong \lambda E-B$$
  4. $$转置 A^{T}\sim B^{T} $$

必要条件:

  1. 行列式,秩、迹相同
  2. 都可或不可对角化
  3. 特征值相同,且特征值对应特征向量个数相同
  4. A B可逆条件下,A逆相似B逆,A逆+A相似B逆+B

数一2018.5

$$
证 (\begin{matrix}
1&1&0\
0&1&1\
0&0&1\
\end{matrix}) \sim (\begin{matrix}
1&1&-1\
0&1&1\
0&0&1\
\end{matrix})
$$

实对称矩阵相似对角化

实对称矩阵可以相似对角化 数学归纳法证明
https://www.bilibili.com/video/BV1sL4y1K7ce

矩阵特质值特征向量与相似关系

矩阵A的函数f(A)的特征值对应变化,特征向量不变,相似矩阵的特征向量之间存在关系,可以推导

秩不满不可逆但可能与对角阵相似

*矩阵A的n次方计算
2016数一21

分块矩阵的秩

  1. 向量组(a1,..an)无关,(b1…bn)无关=>(a1,..an,b1…bn)无关

  2. 利用1证明
    $$
    r(\begin{matrix}
    A&0\
    0&B\
    \end{matrix})=
    r(\begin{matrix}
    0&B\
    A&0\
    \end{matrix})=
    r(A)+r(B)$$

  3. 可利用2证明
    $$
    r(\begin{matrix}
    A&0\
    C&B\
    \end{matrix})=
    r(\begin{matrix}
    C&B\
    A&0\
    \end{matrix})\geq
    r(A)+r(B)$$

  4. A可逆有(A能够通过行列变换表示C):
    $$
    r(\begin{matrix}
    A&0\
    C&B\
    \end{matrix})=
    r(\begin{matrix}
    C&B\
    A&0\
    \end{matrix})=
    r(A)+r(B)$$

  5. AB可由A列向量线性表示(左行右列)

  6. BA可由A行向量线性表示

  7. 56中当B可逆时,为初等变换,B可由初等矩阵表示

  8. r(A)=r(AT)=r(ATA)=r(AAT)

向量组与矩阵等价差异

向量组等价和矩阵等价不同,向量组等价:两个向量组可相互线性表示。
矩阵等价:通过初等变换相等;
矩阵行等价等价于行向量组等价,列同理;

相似合同等价关系

相似(P逆AP=B)、合同(P转AP=B)、等价(P1AP2=B)关系:在实对称矩阵条件下,相似合同等价,相似可推出等价

施密特正交化

  • 施密特正交化应用于正定二次型中,对称矩阵对角化。当矩阵是实对称矩阵必然有单位正交阵使其与对角阵合同。
  • 注意相似中矩阵相似转化不需要正交化
  • 实对称矩阵不同特质值特征向量必定正交,但非实对称矩阵不同特征值的特征向量不一定正交
  • 矩阵正交化的含义(通过减去两个向量的投影部分实现正交)https://zhuanlan.zhihu.com/p/136627868?utm_id=0

特殊行列式计算

概率论

事件运算准则

似然函数单调,参数越大L越大或越小,则由题目条件确定参数的最大或最小值。
一般L随参数递增,参数越大L越大,θ=min{x1,x2,…,xn}(部分题目中概率密度函数中x>θ,所以可以推出),L递减,θ=max{x1,x2,…,xn}

对于max类型的函数,即非连续的函数随机变量,其分布函数与概率密度通过定义求解,即F(x)=P{f(x)<x},并利用条件将该函数转化为可计算的随机变量的函数。参考2016数一22,23题
随机变量最大值与最小值函数的分布函数求解 2003年数一最后一题

指数分布的无条件性

大数定律

  • https://zhuanlan.zhihu.com/p/165479232?utm_id=0
  • https://zhuanlan.zhihu.com/p/259280292?utm_id=0

无偏性与相合性有效性
https://www.zhihu.com/question/22983179?utm_id=0

  • 无偏性即参数的期望等于该参数,如正态总体样本方差的定义中除的是(n-1)而不是n,就是该原因。参考2015数一23题
  • 相合性(一致性),有偏估计中偏差值随着样本增大而减小,即表示具有一致性
  • 有效性,如果估计的参数计算出样本的方差越小即越有效

区间估计
https://zhuanlan.zhihu.com/p/96832616?utm_id=0

  • 单正态总体的样本均值、方差与总体样本方差之间存在一些特殊的分布,可以实现方差已知和未知条件下均值的区间估计,有卡方和T分布
  • 两个正态总体的样本通过F分布,估计其中一个总体的均值

*独立性证明

*随机变量函数分布求解

错题

原文链接:408难点汇总查找

计算机组成原理

中断包括中断隐指令和中断服务程序,中断隐指令是中断过程中除去中断服务程序硬件实现的执行部分。

中断向量地址与中断服务程序地址:每个能向cpu提出中断的设备都有一个中断信号。所有中断源都需要对应的中断处理程序。中断向量地址即由所有中断源的信号产生,能够通过中断向量地址找到中断向量,通过中断向量可找到中断服务程序入口地址。

DMA存在不同设计结构可适用高速和低速设备

DMA周期窃取方式时,IO访存优先级高于CPU

操作系统

计算机网络

数据结构

原文链接:英语一应用文写作

application writing英语一应用文写作

体裁genre

主体为信件letter,Notice次,以及告示、报告、留言、便签

主要内容有:建议、道歉、感谢、推荐、欢迎、邀请、答复、通知

写作框架

  1. 称呼,
  2. ——
  3. 介绍个人
  4. 写信目的
  5. ——
  6. 分点语句(三点)
  7. ——
  8. 结尾 谢+联+回

称呼

dear

  1. 政 Officer Governor
  2. 工 Hiring Manager
  3. 名 Professor Editors
  4. 众 Customers Students Employees
  5. 通 Sir or Madam

i am the resident lived in… /as a reader ,i always appreciate…

  1. 个 Reader Resident Citizen
  2. 官 President

Dear Editors,
Ss a faithful reader of your newspaper. I always appreciate your insightful report of social issues.

目的

I am writing to express my concern over the abuse of plastic bags

  1. 建议 suggestion advice
  2. 道歉 apology
  3. 感谢 gratification
  4. 询问 inquire weather if
  5. 特殊 concern resignation…

分点

pieces of relevent information are as follows.

to begin with,furthermore,what’s more,besides,however,in addition,additionally

i am extremely grateful for your understanding

please freely contact me if your have any questions about the details

i am looking forward to your reply without further delay.

templates真题模板

  1. 2005 工作信:辞职
    two months ago you got a job as an editor for the mangine Desgins&Fasions.
    But you find that the job is not what you expected. you decide quit.
    Write a letter to your boss mr.wang, telling him your decision,stating your reason and making an apology.

  2. 2006 政务信:援助
    You want to contribute to project hope by offering financial aid to a child in a remote area.
    writing a letter to the department concerned,asking them to help finding a candidate.you should specify
    what kind of child you want to help and how you will carry out your plan.

  3. 2007 建议信:图书馆
    writing a letter to your university library,making suggestion for improving its service.

  4. 2008 私人信:道歉
    you have just come back from canada and find a music cd in your luggage that you forgot to return bob,
    your landlord there.writing him a letter to 1.making apology 2.suggest a solution.

  5. 2009 建议信:报社
    white pollution ,plastic bag ignoring the restrictions. 1. give opinion 2.suggestion

  6. 2010 对众通知:协会志愿
    you write for association a notice to recruit volunteers for international conference.
    notice include basic qualifications and other information

  7. 2011 私人信:推荐
    write to friends to recommend movies and reasons.

  8. 2012 对众信:欢迎+建议
    extend welcome and provide suggestions as students union for international students.

  9. 2013 邀请信:教授
    invite a teacher in your college to be a judge for an english speech contest.

  10. 2014 私人信:建议
    write to president of your university about improving physical condition.

  11. 2015 对众信:推荐
    write email to club member as a host recommending book with reasons

  12. 2016 对众通知:介绍
    providing information for international students newly-enrolled as a librarian in university.

  13. 2017 私人信:推荐
    write to professor to recommend tourist attractions with reasons in your city.

  14. 2018 对众信:邀请
    write an email to exports on campus inviting them to a graduation ceremony with details about time,place,others.

  15. 2019 对众回信:答疑
    write an email to answer the inquiry from an volunteer in university,specifying details.

  16. 2020 对众通知:竞赛
    stu union assign you to inform the singing contest for international stus.

  17. 2021 私人信:建议
    write to your friend to give suggestions about hunting job.

  18. 2022 私人信:邀请
    invite professor to organize a team for international innovation contest.

  19. 2023 通知

  20. 2024 信体


  1. 2005 工作信:辞职
    two months ago you got a job as an editor for the mangine Desgins&Fasions.But you find that the job is not what you expected. you decide quit.Write a letter to your boss mr.wang, telling him your decision,stating your reason and making an apology.

    1
    2
    3
    4
    5
    6
    dear mr.wang,
    i appreciate for the opportunity of working here for two months as an editor for mangine Desgins&Fasions,and particularly your constant assistance.however,i am writing formally to give notice of resignation from my post due to personal reasons.
    As a young man whose prmary interest is in computer programming rather than fashion designing,i find my present job does notaccord closely with my previous training and strength.Therefore, i decide to vacate this job and find another one that better matches my educational background.
    please accept my sincerely apology for any inconvenience my leaving may cause.i will do my utmost to assist in the hand-over process.
    your sincerely,
    li ming
  2. 2006 政务信:援助
    You want to contribute to project hope by offering financial aid to a child in a remote area.
    writing a letter to the department concerned,asking them to help finding a candidate.you should specify
    what kind of child you want to help and how you will carry out your plan.

    1
    2
    3
    4
    5
    6
    dear officer,
    As a resident living in my country, it is my honor to provide assistance to a child in need in a remote area. Therefore, I have made the decision to provide financial aid to a child.
    i would be deeply grateful if you could help me seek out a girl who has just started schooling in a remote and poor area.besides,the plan i consider which may not so grateful isto pay her tuition fee and expenses in daily life till she finish the second term next year for nearly six months.further more,i would like to pay the donation directly to the bank account controled herself.
    please contact me if you have any other questions about the plan or find a proper candidate.i will be extremely grateful if you can help me.
    your sincerely,
    li ming
  3. 2007 建议信:图书馆
    writing a letter to your university library,making suggestion for improving its service.

    1
    2
    3
    4
    5
    6
    dear sir or madam,
    I am a student at our university's law school, and I am writing to provide some useful suggestions for improving our library services.
    to begin with,will you consider installing air-conditioner for the whole library before this summer?it is totally hot when we are working or learning at the reading room in the library.in addition,Many students hope that the manager can provide a more spacious room for studying due to the increasing population preparing for exams.this will benefit for all the students at school.
    i would like to extend my greatest appreciation if you are going to take my suggestions into consideration.i am extremely grateful for your understanding.
    your sincerely,
    liming
  4. 2008 私人信:道歉
    you have just come back from canada and find a music cd in your luggage that you forgot to return bob,
    your landlord there.writing him a letter to 1.making apology 2.suggest a solution.

    1
    2
    3
    4
    5
    6
    dear bob,
    i am writing to make an apology to you for my mistake about finding your music cd in my luggage.it is not until the time i arrived at home from Canada that i found it.
    to make up for my fault,i will send this cd back to you through EMS along with an extend cd you would prefer as a token of my apology.it will reach you in about one week.besides, i will bring special gift for you when i go back.
    i would like to express my sincere apology for any inconvenience it may cause.i am looking fowrard to your rely soon.
    your sincerely,
    li ming
  5. 2009 建议信:报社
    white pollution ,plastic bag ignoring the restrictions. 1. give opinion 2.suggestion

    1
    2
    3
    4
    5
    6
    dear editors,
    as a fatihful reader of your newspaper, i always appreciate your insightful report of social issues.i am writing to express my suggestion regarding the issue of white pollution caused by abusing plastic bags.
    from now on, the problem of white pollution are still existed in some regions while the regulations which issued by goverment was despited.to solve the problem,i believe it is urge enough for the goverment to further control this kind of phenomenon which may cause a deeply passive influence to the environment.besides, i perfer social media raher than traditional methods to help adovcating the importance of environment protection.
    i will be extremely grateful if you can take my suggestions into consideation.i sincerely hope our living environment can be more and more beautiful.
    your sincerely,
    li ming
  6. 2015 对众信:推荐
    write an email to club member as a host recommending a book with some reasons.

    1
    2
    3
    4
    5
    6
    dear friends,
    as a host of upcoming reading session,i am writing to you to recommend a plain but moving book,we three,written by yangjiang,one of the most talent contemporary famale writers.
    with her greatest wisdom and perservence,yangjiang tells us love and support between her daughter,husband and her more than 60 years,and he experiences of being happily together and heartbreakingly apart.by depiciting the dreams as well as realities,this book shows us sorrows and joys in life.in addition,through this common but extraordinary family,we can see the personality of intellectuals at that time-cherishing their families and being diligent in their studies, and can deely realize the true meaning of life that happiness always comes along with troubles.
    i hope you will enjoy the book like me and share your impressions of it during the session.
    yours sincerely,
    li ming
  7. 2016 对众通知:介绍
    please provide information for international students newly-enrolled as a librarian in university.

    1
    2
    3
    4
    5
    6
    dear sir or madam,
    as a dedicated student who currently volunteers as a librarian,i am delighted to provide essential information about our library.
    first and foremost,every student is required to present and varify their id card which serves as identifying basic information upon entering the library.in addition,if you want to borrow books for reading,the books need be processed by librarians on the first floor of library and the borrowing peroid is limited to two months.furthermore,smoking and eating are strictly prohibited within the premises of the library.
    i am grateful for your understanding.should you have any extern questions about these rules,please do not hesitate to contact me.
    yours sincerely,
    li ming
  8. 2017 私人信:推荐
    write to professor to recommend tourist attractions with reasons in your city.

    1
    2
    3
    4
    5
    6
    dear prefessor,
    as the president of students' union in out university,i am delighted to recommend some tourist attractions for you if you want to have a trip.
    first and foremost,should you want to visit the iconic architectural masterpiece, the Imperial Palace and the Tiananmen Square is the place for it.the Imperial Palace was first built in Ming dinasity when the monarch migrate the capital to BeiJing in thriteen century while the Tiananmen Square built in is in front of it.besides,the Great Wall where the location is far away the center of the city is also a nice choice for trip.in addition, the Palace Museum which is inner the Imperial Palace collecting plentiy of masterpieces of antiques is popular for tourists.
    your considering about these recommendation are greatly appreciated.should you have any further quesions about these places,please freely contact me.I am looking forward to your reply soon.
    yours sincerely,
    li ming

原文链接:英语一图画写作drawing writing

drawing writing

高级句型

句型 介绍 示例
状语从句 对句子补充,能补充任意信息如时间条件对象 he dead at the beginning of 13th century.he dead before 13th century
定语从句 主语是从句的宾语或主语 a man who looks aged.the building we mention yestarday is the place we meet.
表语从句
伴随状语 伴随状语和定语从句的逗号无严格限制 a boy is young,gaming with friends
同谓语从句 从句是一个完整句子对主语补充,和定语从句界限不明显,无需过度解读 a city that it has many wonders/remarkable spectacles is popular
嵌套从句 从句可以嵌套 the phone that the man who is aged brought is cost effective(定语+定语)
强调句 it is that…将任何句子中强调部分放入is后面即可 It is amazing that an aged man who looks plays with his child.
倒装句 only … can
插入语 作文不建议,降低句子逻辑程度

高级替换

词汇替换 不能出现前面任何词汇
now currently
strange weird
important significant,emphatic,critical,vital,essential
people individual,resident,citizen
very extremely
different various,varient
show reveal,suggest,depict,indicate
in my opinion to my understanding据我所知
think deem
enverionment scene,scenario
actually admittedly
some several
句型替换
for only one week the preiod is limited to one week
more and more an increasing number of,increasingly better
lots of people A considerable number of people
a lot of a host of
for example a case in point

基础写作框架

1-3第一段,4-6第二段,7-9第三段

  1. 描图
    A man/the drawing/there is…

  2. 加文字
    the caption read/the man in the drawing says…

  3. 作者含义
    The author’s purpose extends beyond the picture itself, focusing on what lies beneath the surface of the drawing.

  4. 实际意义
    Acutally, the purpose of drawing is to show us that…

  5. 换句话说
    In other words,Put simply, the primary cause of this phenomenon is people’s disregard for rules in the corresponding environment

    according to latest survey conducted by goverment,approximately all citizens exhibit this undesirable habit.

  6. 反问
    So how can we do to avoid being irrational?

  7. 个人观点
    In my opinion, taking all aspects of this phenomenon into account, we should adhere to our original intention.

  8. 某一方面
    in term of environment, we should proactively contribute our own efforts.

  9. 结尾升华
    Only by doing so can we unlock the true potential of renewable energy and pave the way for a sustainable future.

Not until we have taken active measures to do so shall we secure for ourselves a prosperous and promising future

Only through the diligent pursuit of such endeavors can we truly pave the path towards a luminous and auspicious future.

  1. 2015
    1
    2
    3
    4
    5
    6
    there are four friends get together to have a dinner.what's weird is that the four appear to stranger to each other,not talking with friends seated beside but totally indulging in smart phones.

    the phenomenon reflected in the picture is not rare nowadays,as we always read news that face-to-face communication which was taken for granted has been violently ruined by smart phones and become a luxury.

    reasons that why this kind of phenomenon occers from time to time are various.one of the possible causes is rapid development of electric communication and internet.it is also owing to the fact of the change in social atmosphere.
    in any case,however,the smart phone could never be the excuse for indulging in it.hence one should start to avoid being addited to the entertainment of smart phones to prevent this scence from occurring. additionally, efforts of individuals should be supplemented by communicating with their friends and faimilies more,for example,go out on vacation,climbing,hiking with friends is better than stay at home,which would be of great signigicance to return to normal.

石雷鹏写作框架(高级)

1-2第一段
3-5第二段
6第三段

  1. 描图
    these drawings.in the left one,there is …in the right one,…

  2. 描字
    finally,several chinese characters can be noticed below the picture,which say that…

  3. 现象描述
    to my understanding,can be likened to …

  4. 双面阐述
    on the one hand, a case in point is the scene in the left picture.however,on the other hand,… a typical example is the scenario in the right.

  5. 提出担忧
    admittedly,an increasing number of youngsters…this phenomenon is partically worth attention.

  6. 个人总结

石雷鹏预测作文一:科技双刃剑
these two drawings are simple but satirical.in the left one,there is a girl,setting in front of a computer and typing so many words with no difficulty.however,in the right one,without the help of modern technology, the girl has great trouble in writing words on paper,with the throught in her mind:i need to look them up on my cell phone.finally,several chinese characters can be noticed below the picture,which say that science and technology has changed people’s habits.

the fast development of science and technology,to my understanding,can be likened to a double-edged wsword.on the one hand,a host of innovative technological products can bring us greate convenience,help us save time and enhance our working efficiency.a case in point is the scene in the left picture.on the other hand,it is modern technology that cause some young people to lose certain basic skills in life,work and study.a typical example is the scenario in the right.admittedly, an increasing number of youngsters ,now, forget how to write some common words that they learned in elementary school.this phenomenon is partically worth attention.

as a youngster,i deem that it is advisible for us to utilize smart technological products in rational manner,including the computers,cell phones and the like.

  1. 2016

原文链接:python模块:Scipy.optimize.linprog线性规划求解

一、模块介绍

1.1模块功能

Scipy.optimize是Scipy中一个用于解决数学模型中优化类模型的子包,该子包中又包含了多个子功能模块见下表,不同方法不同条件求解最优化模型。本节介绍linprog对线性规划问题的模型建立与求解。

Read more »

原文链接:python模块:Scipy.optimize.minimize规划问题求解

一、模块介绍

1.1模块功能

        Scipy.optimize是Scipy中一个用于解决数学模型中优化类模型的子包,该子包中又包含了多个子功能模块见下表,不同方法不同条件求解最优化模型。本节介绍minimize对一般规划问题的模型建立与求解。

Read more »

原文链接:408-theory-Data-Structure

线性表 Linear List

结构

顺序表 Sequential List

链表 Linked List

带头结点和不带头结点两种实现,带头结点保证插入删除的一致性

单链表 Singly Linked List

双向链表 Doubly Linked List

循环链表 Circular Linked List

循环单链表 Circular Singly Linked List
循环双链表 Circular Doubly Linked List

基本函数

  • ListInit(&L);初始化
  • ListLength(L);计算表长
  • ListEmpty(L);判断表空
  • ListPrint(L);输出表
  • LocateElem(L,e);按值查找
  • GetElem(L,i);下标查找
  • ListInsert(&L,i,e);插入
  • ListDelete(&L,i,&e);删除
  • ListDestroy(&L);摧毁
Read more »