XpandNotes

exploring the intersection of technology and creativity

使用 c++ 計算行列式

降階公式 這是一個常用的行列式降階公式,這裡有證明,雖然我是看不懂維基百科的證明啦,而且大一線代課的內容也忘得差不多了,之後有機會得再翻翻線代教科書好好複習一下了 圖片來源 https://en.wikipedia.org/wiki/Determinant 以上面的 3 × 3 行列式為例,依序取 a, b, c 為基準,並忽略 a, b, c 所在的行列,製造三個子行列式,也就是...

使用 c++ 實作高斯消去

因為 COVID-19 疫情,線代的小考改為寫程式實作一些常用的矩陣運算,雖然網路上應該有很多完整又高效的函式庫可以用,但我覺得親手實作一次也算是個很好的練習。這篇文章將紀錄如何使用 c++ 做高斯消去,而之後做 PLU 分解時,就會再次利用這段 code 求上三角矩陣。 高斯消去 一般高斯消去時是使用增廣矩陣,但這份程式原本的用途是求上三角矩陣,所以這裡以普通的矩陣作為例子。在下面的例...

計算機組織: mips 實作階乘和費氏數列

Factorial $ F(n) = \begin{cases} 1, & n\mbox{ = 0} \\ F(n - 1) * n, & n \in \mathbb{N} \end{cases} $ 使用 $a0 做為參數,以這個程式為例,令 $a0 等於 5 然後跳到 fact 標籤就表示 F(5),在遞迴結束時,計算結果會顯示在 $v0 1 2 3 4 5 6 ...

離散數學: 渡河問題

雞、狗、菜和農夫過河問題

題目敘述 A farmer has a ship, a chicken, a bag of rice, a dog. He need to take all of them cross the river. But, this ship is too small. He only can take two of them together in his ship. But,...

java 爬蟲教學

這篇教學會利用 jsoup 函式庫寫出一個爬取單一網頁並擷取網頁內所有文字的爬蟲,也算是一個筆記,以防自己將來需要用到這個程式的時候要 trace 半天才看得懂… 使用環境 Ubuntu 18.04 openjdk version “1.8.0_242” jsoup 1.13.1 我沒有使用 maven 管理 java 套件,都是用手動管理的(之後學會用 maven 再補上 pom),...

Hadoop 3.2.1 安裝教學

最近正在學習 Hadoop,發現 Hadoop 的安裝過程繁瑣,每個人的裝置又可能產生不一樣的問題,且中文資源較少,所以想好好寫個筆記紀錄一下,未來安裝 Hadoop 時可以參考,同時也希望能幫助新手 Step 1: 安裝 java 打開 terminal 運行以下指令 $ sudo apt install openjdk-8-jre-headless $ sudo apt insta...

Pointer, Function, Structure

Pointer and Structure Pointers can also points to user-defined structures: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 #include<iostream> #include<string> using namesp...

Pointer (2)

Pointer Arithmetic In the previous post, we mentioned that an array is actually a pointer. Array pointers support to return a shifted address via + operator and - operator. Now we learn how to shi...

Pointer (1)

Pointer Variables The concept of pointer in C++ is quite important for developing class. Before talking about pointer, let’s learn to find the address of a variable by & (address) operator. 1...

Union and Enumeration

Union A union, like a structure, consists of several members, possibly of different types. The compiler allocates only enough space for the largest of the members, which overlay each other within ...