机器学习之线性代数
1. 范数:啥事范数,有什么用
极大似然估计是啥
2.什么事正则化
什么事正则化项
什么事泛函
#ifndef NUMBER_THEORY_H
#define NUMBER_THEORY_H
#define dType int
// 阶乘
dType factorial(dType n);
// 组合
// n: 总数 m:选取数
dType combination(dType n, dType m);
//求素数
dType primeNum(dType n);
// 最大公约数
dType greatestCommonDivisor(dType m,dType n);
// 最小公倍数
dType leastCommonMultily(dType m,dType n);
#endif
#include<stdio.h>
#include"numberTheory.h"
int main(int argc,char** argv){
int num;
//scanf("%d",&num );
//printf("%d\n", factorial(num));
//printf("%d\n", combination(10,2));
//for(int i=2;i<100;++i)
// if(primeNum(i)) printf("%d\n", i );
//printf("%d\n",leastCommonMultily(6,9));
return 0;
}
#include<math.h>
#include"numberTheory.h"
// 阶乘
dType factorial(dType n){
dType fac =1;
for(dType i=1;i<=n;++i)fac*=i;
return fac;
}
// 组合
// n: 总数 m:选取数
dType combination(dType n, dType m){
return factorial(n)/factorial(m)/factorial(n-m);
}
//求素数
dType primeNum(dType n){
if(n==2) return n;
dType lNum = sqrt(n)+1;
for(dType i=2;i<lNum;++i)
if(n%i == 0) return 0;
return n;
}
// 最大公约数
// 辗转相除法
dType greatestCommonDivisor(dType m,dType n){
dType gcd=m;
m = m>n?m:n;
n = gcd<n?gcd:n;
while(m%n){
gcd = m%n;
m = n;
n = gcd;
}
return n;
}
// 最小公倍数
dType leastCommonMultily(dType m,dType n){
return m*n/greatestCommonDivisor(m,n);
}
main.exe: numberTheory.o main.o
gcc -o main.exe numberTheory.o main.o
main.o: numberTheory.h
gcc -c -o main.o main.c
numberTheory.o: numberTheory.h
gcc -c -o numberTheory.o numberTheory.c
clean:
del main.o main.exe numberTheory.o
makefile
- make 会根据文档修改时间进行比对,然后确认是否要重新编译
- 不止gcc可以 使用,任何语言均可,同时相关规则性操作均可
makefile形式
target:prerequisites
recipe
target:目标文件,一版为 obj 或者 可执行文件 或 可以执行的命令
prerequisite:依赖
recipe:编译命令,行首需要一个TAB空格
gcc命令参数使用说明
makefile 执行错误:missing separater
观察gcc等前面是否缺少 tap键
《GNU make》 https://www.gnu.org/software/make/manual/make.html
- 数组时引用变量,因此定义数组时不能指定长度