6.CAP原则与Raft协议
雷神之锤3 的源代码查看
Quake-III Arena (雷神之锤3)是90年代的经典游戏之一。该系列的游戏不但画面和内容不错,而且即使计算机配置低,也能极其流畅地运行。这要归功于它3D引擎的开发者约翰-卡马克(John Carmack)。事实上早在90年代初DOS时代,只要能在PC上搞个小动画都能让人惊叹一番的时候,John Carmack就推出了石破天惊的Castle Wolfstein, 然后再接再励,doom, doomII, Quake…每次都把3-D技术推到极致。他的3D引擎代码资极度高效,几乎是在压榨PC机的每条运算指令。当初MS的Direct3D也得听取他的意见,修改了不少API。
最近,QUAKE的开发商ID SOFTWARE 遵守GPL协议,公开了QUAKE-III的原代码,让世人有幸目睹Carmack传奇的3D引擎的原码。这是QUAKE-III原代码的下载地址:
http://www.fileshack.com/file.x?fid=7547
(下面是官方的下载网址,搜索 “quake3-1.32b-source.zip” 可以找到一大堆中文网页的。ftp://ftp.idsoftware.com/idstuff/source/quake3-1.32b-source.zip)
我们知道,越底层的函数,调用越频繁。3D引擎归根到底还是数学运算。那么找到最底层的数学运算函数(在game/code/q_math.c), 必然是精心编写的。里面有很多有趣的函数,很多都令人惊奇,估计我们几年时间都学不完。在game/code/q_math.c里发现了这样一段代码。它的作用是将一个数开平方并取倒,经测试这段代码比(float)(1.0/sqrt(x))快4倍:

w3cschool官方公众号:w3c技术教程,每天分享各种技术干货以及有趣的科技新闻。

LightGBM算法原理及Python实现
(1) 初始化模型
首先,初始化一个简单的模型,通常是一个常数模型,记为
\(f_0(X)\),其预测值为所有样本真实值的均值(回归任务)或多数类(分类任务),记为
\(\hat y_0\)。此时,模型的预测结果与真实值之间存在误差。
什么是Python?对于初学者意味着什么?
同学你知道什么是python吗?你知道python对于初学者意味着什么吗?如果不知道也没关系。今天这篇文章 w3cschool 小编来为大家解答一下这个问题。
什么是python?
python 是一种面向对象、解释型的计算机程序设计脚本语言。python 的设计具有很强的可读性,具有比其他语言更特色的语法结构。python 在开发过程中是没有编译的环节的,因为它是解释型语言。python 对初级程序员来说,是一种快速上手的语言,它支持广泛的应用程序开发,从简单的文字处理到 WWW 浏览器再到游戏。
对于初学者意味着什么?
如今 python 语言的谈论程度正热,就目前招聘来说,python 工程师人才需要同比增长79.1%(2018年数据)。而 python 所能从事的主要岗位集中在大数据分析,人工智能和自动化方向,也是近几年来热门行业。所以学习 python,对于初学者来说,是一个提升自我,升职加薪的好机会,学习 python 将对以后你的职业生涯提供不少的帮助。
以上就是关于话题“什么是Python?对于初学者意味着什么?”的全部回答。更多 python 学习请关注 python 编程狮。
uv全功能更新:统一管理Python项目、工具、脚本和环境的终极解决方案

国家教育部:AI、算法等2018年进入全国高中课程!
日前,教育部召开新闻发布会,介绍了《普通高中课程方案和语文等学科课程标准(2017年版)》的有关情况,并重新修订了语文等14门学科的课程标准。在此次“新课标”改革中,正式将人工智能、物联网、大数据处理正式划入新课标。
高中信息技术必修课程是全面提高高中生信息素养的基础,包括“数据与计算”和“信息系统与社会”两个模块。
修订版本的方案中,把高中学习内容分成了必修课、选择性必修课和选修课。见下表1!
数据与计算:
- (1)了解数据编码
- (2)学会采集、分析、可视化数据
- (3)学会一种程序语言,并使用程序语言完成简单的算法
- (4)了解人工智能的重要性
信息系统与社会
- (1)知道信息系统基本工作原理
- (2)可以开发简单的信息系统
- (3)判断安全风险,了解安全防范技术
- (4)学会遵守相关法律和道德伦理规范
基于Jetson Nano与PyTorch的无人机实时目标跟踪系统搭建指南
本文通过完整的工程实现,展示了从算法部署到系统集成的完整流程。实际测试表明,该系统在Jetson Nano上可达:
Linux之父27年前写的一段代码
有程序员网友曝出了莱纳斯•托瓦尔兹(Linus Torvalds) 1991 年公开的 Linux 源代码,这引起了 W3Cschool 的注意,可以研究一下这位大神的代码:
源码:
/
system_call.s contains the system-call low-level handling routines.
This also contains the timer-interrupt handler, as some of the code is
the same. The hd-interrupt is also here.
NOTE: This code handles signal-recognition, which happens every time
after a timer-interrupt and after each system call. Ordinary interrupts
don't handle signal-recognition, as that would clutter them up totally
unnecessarily.
Stack layout in 'ret_from_system_call':
0(%esp) - %eax
4(%esp) - %ebx
8(%esp) - %ecx
C(%esp) - %edx
10(%esp) - %fs
14(%esp) - %es
18(%esp) - %ds
1C(%esp) - %eip
20(%esp) - %cs
24(%esp) - %eflags
28(%esp) - %oldesp
2C(%esp) - %oldss
/
SIG_CHLD = 17
EAX = 0x00
EBX = 0x04
ECX = 0x08
EDX = 0x0C
FS = 0x10
ES = 0x14
DS = 0x18
EIP = 0x1C
CS = 0x20
EFLAGS = 0x24
OLDESP = 0x28
OLDSS = 0x2C
state = 0 # these are offsets into the task-struct.
counter = 4
priority = 8
signal = 12
restorer = 16 # address of info-restorer
sig_fn = 20 # table of 32 signal addresses
nr_system_calls = 67
.globl _system_call,_sys_fork,_timer_interrupt,_hd_interrupt,_sys_execve
.align 2
bad_sys_call:
movl $-1,%eax
iret
.align 2
reschedule:
pushl $ret_from_sys_call
jmp _schedule
.align 2
_system_call:
cmpl $nr_system_calls-1,%eax
ja bad_sys_call
push %ds
push %es
push %fs
pushl %edx
pushl %ecx # push %ebx,%ecx,%edx as parameters
pushl %ebx # to the system call
movl $0x10,%edx # set up ds,es to kernel space
mov %dx,%ds
mov %dx,%es
movl $0x17,%edx # fs points to local data space
mov %dx,%fs
call _sys_call_table(,%eax,4)
pushl %eax
movl _current,%eax
cmpl $0,state(%eax) # state
jne reschedule
cmpl $0,counter(%eax) # counter
je reschedule
ret_from_sys_call:
movl _current,%eax # task[0] cannot have signals
cmpl _task,%eax
je 3f
movl CS(%esp),%ebx # was old code segment supervisor
testl $3,%ebx # mode? If so - don't check signals
je 3f
cmpw $0x17,OLDSS(%esp) # was stack segment = 0x17 ?
jne 3f
2: movl signal(%eax),%ebx # signals (bitmap, 32 signals)
bsfl %ebx,%ecx # %ecx is signal nr, return if none
je 3f
btrl %ecx,%ebx # clear it
movl %ebx,signal(%eax)
movl sig_fn(%eax,%ecx,4),%ebx # %ebx is signal handler address
cmpl $1,%ebx
jb default_signal # 0 is default signal handler - exit
je 2b # 1 is ignore - find next signal
movl $0,sig_fn(%eax,%ecx,4) # reset signal handler address
incl %ecx
xchgl %ebx,EIP(%esp) # put new return address on stack
subl $28,OLDESP(%esp)
movl OLDESP(%esp),%edx # push old return address on stack
pushl %eax # but first check that it's ok.
pushl %ecx
pushl $28
pushl %edx
call _verify_area
popl %edx
addl $4,%esp
popl %ecx
popl %eax
movl restorer(%eax),%eax
movl %eax,%fs:(%edx) # flag/reg restorer
movl %ecx,%fs:4(%edx) # signal nr
movl EAX(%esp),%eax
movl %eax,%fs:8(%edx) # old eax
movl ECX(%esp),%eax
movl %eax,%fs:12(%edx) # old ecx
movl EDX(%esp),%eax
movl %eax,%fs:16(%edx) # old edx
movl EFLAGS(%esp),%eax
movl %eax,%fs:20(%edx) # old eflags
movl %ebx,%fs:24(%edx) # old return addr
3: popl %eax
popl %ebx
popl %ecx
popl %edx
pop %fs
pop %es
pop %ds
iret
default_signal:
incl %ecx
cmpl $SIG_CHLD,%ecx
je 2b
pushl %ecx
call _do_exit # remember to set bit 7 when dumping core
addl $4,%esp
jmp 3b
.align 2
_timer_interrupt:
push %ds # save ds,es and put kernel data space
push %es # into them. %fs is used by _system_call
push %fs
pushl %edx # we save %eax,%ecx,%edx as gcc doesn't
pushl %ecx # save those across function calls. %ebx
pushl %ebx # is saved as we use that in ret_sys_call
pushl %eax
movl $0x10,%eax
mov %ax,%ds
mov %ax,%es
movl $0x17,%eax
mov %ax,%fs
incl _jiffies
movb $0x20,%al # EOI to interrupt controller #1
outb %al,$0x20
movl CS(%esp),%eax
andl $3,%eax # %eax is CPL (0 or 3, 0=supervisor)
pushl %eax
call _do_timer # 'do_timer(long CPL)' does everything from
addl $4,%esp # task switching to accounting ...
jmp ret_from_sys_call
.align 2
_sys_execve:
lea EIP(%esp),%eax
pushl %eax
call _do_execve
addl $4,%esp
ret
.align 2
_sys_fork:
call _find_empty_process
testl %eax,%eax
js 1f
push %gs
pushl %esi
pushl %edi
pushl %ebp
pushl %eax
call _copy_process
addl $20,%esp
1: ret
_hd_interrupt:
pushl %eax
pushl %ecx
pushl %edx
push %ds
push %es
push %fs
movl $0x10,%eax
mov %ax,%ds
mov %ax,%es
movl $0x17,%eax
mov %ax,%fs
movb $0x20,%al
outb %al,$0x20 # EOI to interrupt controller #1
jmp 1f # give port chance to breathe
1: jmp 1f
1: outb %al,$0xA0 # same to controller #2
movl _do_hd,%eax
testl %eax,%eax
jne 1f
movl $_unexpected_hd_interrupt,%eax
1: call %eax # "interesting" way of handling intr.
pop %fs
pop %es
pop %ds
popl %edx
popl %ecx
popl %eax
iret
Linux之父
托瓦尔兹 1969 年 12 月 28 日出生于芬兰赫尔辛基市,父母都是记者。他从小就对计算机感兴趣。1988 年他进入赫尔辛基大学学习,专业为计算机科学。1991 年,他购买了一台属于自己的 PC 机。赫尔辛基大学当时采用Unix操作系统,托瓦尔兹觉得该产品性能不尽如人意,于是就尝试着自己编写一款操作系统内核,这就是 Linux 操作系统来源。
1997 年至 2003 年,托瓦尔兹在美国加州全美达(Transmeta)公司工作。2003 年 7 月,他加盟“开放源代码开发实验室”(OSDL),以全力开发 Linux 内核。后来 OSDL 与“免费标准集团”(FSG)合并成立了 Linux 基金会。托瓦尔兹如今仍在 Linux 基金会工作。与其他 IT 明星人物所不同的是,托瓦兹平常行事较为低调,一般很少在公开场合评论商业竞争对手产品的好坏。
学编程,从w3cschool开始,w3cschool推出的编程微课,能够帮助新手更快地学会一门语言,采用的是一题一练,边学边练的高效学习模式!
有兴趣的童鞋的尝试一下!W3Cschool编程微课
【BLIP】解读BLIP
主流的多模态模型,基本分为两种:基于encoder和基于encoder-decoder。两者都存在一定的劣势,前者不能完成文本生成任务,例如图像字幕生成,而后者基本没有在图像-文本检索的任务上成功过。
Java之父22年前写的一段代码
[Listing One]PingPong class PingPong extends Thread { String word; // what word to print int delay; // how long to pause
PingPong(String whatToSay, int delayTime) { word = whatToSay; delay = delayTime; } public void run() { try { for (;;) { System.out.print(word + " "); sleep(delay); // wait until next time } } catch (InterruptedException e) { return; // end this thread } } public static void main(String[] args) { new PingPong("ping", 33).start(); // 1/30 second new PingPong("PONG", 100).start(); // 1/10 second }}
[Listing Two]
Account class Account {
private double balance;public Account(double initialDeposit) { balance = initialDeposit; } public synchronized double getBalance() { return balance; } public synchronized void deposit(double amount) { balance += amount; }}
[Listing Three]
synchronized_abs /* make all elements in the array nonnegative /
public static void abs(int[] values) {
synchronized (values) {
for (int i = 0; i < values.length; i++) {
if (values[i] < 0)
values[i] = -values[i];
}
}
}[Listing Four]
class Queue {
// The first and last elements in the queue
Element head, tail;public synchronized void append(Element p) { if (tail == null) head = p; else tail.next = p; p.next = null; tail = p; notify(); // Let waiters know something arrived } public synchronized Element get() { try { while(head == null) wait(); // Wait for an element } catch (InterruptedException e) { return null; } Element p = head; // Remember first element head = head.next; // Remove it from the queue if (head == null) // Check for an empty queue tail = null; return p; }}
[Listing Five]
Thread spinner; // the thread doing the processing
public void userHitCancel() {
spinner.suspend(); // whoa!
if (askYesNo("Really Cancel?"))
spinner.stop(); // stop it
else
spinner.resume(); // giddyap!
}[Listing Six]
class CalcThread extends Thread {
private double Result;public void run() { Result = calculate(); } public double result() { return Result; } public double calculate() { // ... }}
class Join {
public static void main(String[] args) {
CalcThread calc = new CalcThread();
calc.start();
doSomethingElse();
try {
calc.join();
System.out.println("result is "+ calc.result()); } catch (InterruptedException e) { System.out.println("No answer: interrupted"); } }}
学编程,从w3cschool开始,w3cschool推出的编程微课,采用游戏化的编程闯关模式,让你快速掌握编程这一门手艺。微课学习入口:W3Cschool编程微课
小狮博客