Rust笔记(三)
所有权和借用 所有权 所有权是用来进行内存管理,使得编译器可以在编译时根据一系列规则来确保内存安全。 所有权原则 Rust 中每一个值都被一个变量所拥有。 一个值同时只能被一个变量所拥有。 当变量离开作用范围时,这个值也会被销毁。 拷贝与移动(move) 深拷贝 Rust 不会自动创建数据的深拷贝,需要使用 clone 方法来创建一个值的深拷贝。 例如 12let s1 = String::from("hello");let s2 = s1.clone(); 浅拷贝 浅拷贝只发生在栈上,实现了 Copy 特征的类型在赋值的时候都会执行浅拷贝。一个基本的规则是:任何基本类型的组合都可以 Copy,不需要分配内存或者某种形式资源的类型也是可以 Copy 的。 包括, 所有整数类型 布尔类型 所有浮点数类型 字符类型 元组类型(如果元组中的所有元素都是 Copy 类型) 不可变引用类型 &T ,但是可变引用类型不可以 Copy 。 Tips as_ 系列方法可以将一个类型转换为另一个类型,但是不会改变值的所有权。 例如 12let s = Str...
Rust笔记(二)
基本数据类型 整型 整型溢出 debug 模式会检查整型溢出,而 release 模式则不会。 显示处理溢出可以使用标准库对原始数字类型提供的方法: wrapping_*:包装溢出,按照补码进行循环。 checked_*:检查溢出,返回 None 值。 overflowing_*:返回补码循环的值和一个指示是否溢出的布尔值。 saturating_*:饱和溢出,限定越界结果为最大值、最小值。 其中 * 表示具体的方法,包括 add, sub, mul, div 等。 浮点类型 Rust 中的浮点类型有两种:f32 和 f64,但是现在CPU中他俩的速度几乎相同,所以默认使用 f64。 浮点数陷阱 因为计算机中的小数用二进制存储,有些在十进制中可以精确表示的数,在计算机中无法精确表示。例如, 1234fn main() { // 断言0.1 + 0.2与0.3相等 assert!(0.1 + 0.2 == 0.3);} 此断言会失败。如果一定要比较,可以使用 (0.1_f64 + 0.2 - 0.3).abs() < 0.00001 来判断。 Na...
How to improve my programming skill?
Path To Programming Master 1. Novice Fully understand and memorize the basic concepts and syntax of the programming language. 2. Proficient Implement classic algorithms and data structures. Complete programming projects independently, following the best practices - not just step-by-step instructions. 3. Master Design and build new programming projects entirely on my own.
Secutity Basics: Chapter 1
Binary File Compiling Process The compilation process can be divided into five main stages: Lexical analysis Syntax analysis Semantic analysis Intermediate code generation Code optimization and generation Compilation Procedure Using GCC Preprocessing: Use the -E option to preprocess the source code. This step expands macros, removes comments, and includes header files. Compilation: Use the -S option to compile the source code or preprocessed code to assembly language (.s file). Assembling:...
模糊测试(一)——AFL++调研记录
What is Fuzz Testing? Fuzz Testing is a software testing technique that employs automatically generated random inputs to identify potential vulnerabilities in software. Fuzz Testing Process The fuzz testing process, illustrated in the Figure below, which can be divided into seed selection, input mutation and result analysis. Important Sub-processes Instrumentation Instrumentation adds hooks to the target program to collect runtime information while preserving the original behavior of the pro...
英语表达
句式 one takes A to mean B: In this paper, we take “efficient” to mean polynomial time. one means B by A: By “efficient,” we mean computable in polynomial time.
近世代数(一)——初步
教材、教程 Garrett Birkhoff, Saunders Mac Lane,《A Survey of Modern Algebra》;中文版:《近世代数概论》,王连祥等译。 整数和环 交换环 ⇔\Leftrightarrow⇔ 满足八条共设 整环 ⇔\Leftrightarrow⇔ 满足八条共设,且满足消去律 消去律:若ccc非零元,且ca=cbca=cbca=cb,则a=ba=ba=b。 在交换环中,乘法消去律 ⇔\Leftrightarrow⇔ 若 ab=0ab=0ab=0 ,则 a=0a=0a=0 或 b=0b=0b=0;也就是说,非零因子之积不为零。 良序原则 ⇔\Leftrightarrow⇔ 数学归纳法 ⇔\Leftrightarrow⇔ 最小反例法 良序原则:每个非空的自然数集合都存在一个最小元素。 数学归纳法:若P(1)P(1)P(1)为真,且对于任意的k,由P(k)P(k)P(k)为真可推出P(k+1)P(k+1)P(k+1)也为真,则P(n)P(n)P(n)对任意自然数都为真。 最小反例法:假设 P(n)P(n)P(n) 对任意自然数都为...
近世代数(零)——Markdown和英语
用得到的符号 集合与逻辑符号 A⊆BA \subseteq BA⊆B 子集 $A \subseteq B$,A⊇BA \supseteq BA⊇B 超集 $A \supseteq B$ 非子集、超集:A⊈BA \not\subseteq BA⊆B,A⊉BA \not\supseteq BA⊇B a∈Aa \in Aa∈A 属于 $a \in A$,a∉Aa \notin Aa∈/A 不属于 $a \notin A$ A∩BA \cap BA∩B 交集 $A \cap B$ A∪BA \cup BA∪B 并集 $A \cup B$ A∖BA \setminus BA∖B 差集 $A \setminus B$ AcA^cAc 补集 $A^c$ ∅\emptyset∅ 空集 $\emptyset$ ∀x,∃y\forall x, \exists y∀x,∃y 全称、存在 $\forall x, \exists y$ ∧,∨,¬\land, ...
RA学习笔记(一)——综述笔记
综述《RAG and RAU: A Survey on Retrieval-Augmented Language Model in Natural Language Processing》粗读
大模型学习笔记(二)——其它知识点总结
如何让模型学习、理解自然语言和世界知识 任务设计 去噪自监督学习(Denoising Auto-Encoding):破坏原文,让模型补充,BERT的MLM(Masked Language Modeling)就是这种任务。 示例: 原文: The chef cooked the meal. 破坏后: The chef [mask] the meal. 主模型的任务: 预测被 [mask] 替换的词是 cooked。 自回归语言建模 (Autoregressive Language Modeling):让模型从左到右逐个预测下一个词。 示例: 输入: 今天天气真不错,我们一起去 模型的目标: 预测出下一个词是 公园、散步 或其他合理的词。 学习到的能力: 这种方法极大地锻炼了模型的生成能力、流畅性和上下文关联能力。因为它必须根据已经出现的所有前文来推断最合理地延续,所以它对语境的理解非常深刻,这也就是为什么GPT系列擅长对话、写作和上下文学习(In-context Learning)。 对比学习 (Contrastive Learning):要求模型学会判断“相似”与“不相似”,将...






