Compare commits

34 Commits
main ... hugo

Author SHA1 Message Date
8ca7d28b8e updated cpp/functions.md 2026-03-09 14:37:00 -05:00
4ab2f02b7d introduced new book 2026-03-05 18:36:59 -06:00
19e0cc3652 updated math syntax 2026-03-03 09:45:04 -06:00
89688be822 removed junk files 2026-03-03 09:41:14 -06:00
c8148d210f updated calciii notes 2026-03-03 09:40:49 -06:00
Lucas Rufkahr
a47803306b updated calc iii notes 2026-03-02 22:36:32 -06:00
lucasrufkahr
a3b5d0f16d updated homepage 2026-03-02 21:26:13 -06:00
Lucas Rufkahr
dfcf5e5b10 updated header and footer 2026-03-02 21:25:17 -06:00
Lucas Rufkahr
dfe03bdbbc updated calc ii 2026-03-02 21:20:00 -06:00
Lucas Rufkahr
96ef87b663 updated mathjax, added calc iii notes 2026-03-02 21:12:34 -06:00
Lucas Rufkahr
c3dd0c0dd8 added latex support 2026-03-02 20:02:34 -06:00
lucasrufkahr
7d47306f4f fix tag 2026-03-02 18:52:34 -06:00
Lucas Rufkahr
e8b63414f0 created linux category 2026-03-02 18:51:39 -06:00
b0dc2399c7 update functions.md 2026-03-02 14:48:38 -06:00
lucasrufkahr
91628c023e a 2026-03-02 14:41:27 -06:00
48746c973c update style of codeblocks 2026-03-02 14:36:40 -06:00
15defb66ed update functions page 2026-03-02 14:32:52 -06:00
3a42126ede update functions page 2026-03-02 14:32:04 -06:00
332683b007 update hugo 2026-03-02 14:05:16 -06:00
lucasrufkahr
4c317411ca removed css 2026-02-28 23:00:32 -06:00
lucasrufkahr
4b9cc82c6c add build script 2026-02-28 22:58:37 -06:00
d8f1c3e4f0 updated templates 2026-02-28 22:56:04 -06:00
7042cd65b9 removed draft 2026-02-28 22:39:02 -06:00
7eabc003d3 updated 2026-02-28 22:33:40 -06:00
fdfe0c9983 updated hugo site 2026-02-28 22:23:50 -06:00
797892adef Updated hugo site 2026-02-28 10:23:39 -06:00
d80acc7860 updated hugo site 2026-02-28 00:59:59 -06:00
42a02d30ec test 2026-02-27 22:58:11 -06:00
e1c7110db0 test 2026-02-27 22:41:38 -06:00
18be029905 removed files 2026-02-27 22:40:04 -06:00
ed97ed3051 added hugo files 2026-02-27 22:39:27 -06:00
18e8886c41 added hugo files 2026-02-27 22:36:11 -06:00
88956b969d cleanup 2026-02-27 22:35:30 -06:00
f085cde245 test 2026-02-27 22:34:34 -06:00
43 changed files with 1047 additions and 163 deletions

4
.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
public/
public/*
.hugo_build.lock

10
.idea/.gitignore generated vendored Normal file
View File

@@ -0,0 +1,10 @@
# Default ignored files
/shelf/
/workspace.xml
# Ignored default folder with query files
/queries/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
# Editor-based HTTP Client requests
/httpRequests/

8
.idea/modules.xml generated Normal file
View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/website.iml" filepath="$PROJECT_DIR$/.idea/website.iml" />
</modules>
</component>
</project>

View File

@@ -0,0 +1,17 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Start Hugo Server" type="ShConfigurationType">
<option name="SCRIPT_TEXT" value="hugo server -D" />
<option name="INDEPENDENT_SCRIPT_PATH" value="true" />
<option name="SCRIPT_PATH" value="$PROJECT_DIR$/debug.sh" />
<option name="SCRIPT_OPTIONS" value="" />
<option name="INDEPENDENT_SCRIPT_WORKING_DIRECTORY" value="true" />
<option name="SCRIPT_WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="INDEPENDENT_INTERPRETER_PATH" value="true" />
<option name="INTERPRETER_PATH" value="/bin/bash" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="EXECUTE_IN_TERMINAL" value="true" />
<option name="EXECUTE_SCRIPT_FILE" value="true" />
<envs />
<method v="2" />
</configuration>
</component>

6
.idea/vcs.xml generated Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

8
.idea/website.iml generated Normal file
View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

9
archetypes/book.md Normal file
View File

@@ -0,0 +1,9 @@
+++
date = '{{ .Date }}'
draft = true
title = '{{ replace .File.ContentBaseName "-" " " | title }}'
layout = ''
type = 'book'
tags = ''
chapterno = 0
+++

5
archetypes/default.md Normal file
View File

@@ -0,0 +1,5 @@
+++
date = '{{ .Date }}'
draft = true
title = '{{ replace .File.ContentBaseName "-" " " | title }}'
+++

1
build.sh Executable file
View File

@@ -0,0 +1 @@
hugo build -d /home/lucasrufkahr/html

10
content/_index.md Normal file
View File

@@ -0,0 +1,10 @@
+++
date = '2026-02-28T10:28:34-06:00'
draft = false
title = ''
+++
Welcome to the main page. Here you will find some things. Some things here require javascript for mathematical formulas.
{{< booklist >}}

View File

@@ -0,0 +1 @@
{}

View File

@@ -0,0 +1,9 @@
+++
date = '2026-02-28T22:19:00-06:00'
draft = false
title = 'Calculus Notes'
layout = 'frontcover'
type = 'book'
tags = 'calculus'
chapterno = 0
+++

View File

@@ -0,0 +1,65 @@
+++
date = '2026-03-02T19:00:00-06:00'
draft = false
title = 'Function of Several Variables'
layout = 'chapter'
type = 'book'
tags = 'calculus'
chapterno = 15
+++
## Max/Min Problems
-------------------
Definition:
\[
\text{Suppose } (a,b) \text{ is a point in region} R \text{ on which } f \text{ is defined and there is an open disk centered at } (a,b) \text{.}\\\\
\text{If: } f(x,y) \leq f(a,b) \text{, then } f(a,b) \text{ is a local max.}\\
\text{If: } f(x,y) \geq f(a,b) \text{, then } f(a,b) \text{ is a local min.}
\]
Theorem:
\[
\text{If } f \text{ has a local max or min value at } (a,b) \text{ and the partial derivatives } f_x \text{ and } f_y \text{ exist at } (a,b) \text{, then } f_{x}(a,b) = f_{y}(a,b) = 0 \text{.}
\]
If you are at \((a,b)\) and every where you look, the value next to you is higher, you are at a local minimum position. If everywhere you look, the value is lower, you are at a local maximum position.
Critical points are identified by finding where the partial derivatives of each variable in the multi-variate function equals zero.
Definition:
\[
\text{ A critical point in } f \text{ is located as an interior point } (a,b) \text{ if either:}\\\\
f_{x}(a,b) = f_{y}(a,b) = 0\\
f_{x} \text{ or } f{y} \text{ does not exist at } (a,b)
\]
If you are able to find the critical points of \(f\) then you can use the _Second Partial Derivative Test_ to determine the maximum and minimum values.
Theorem:
\[
\text{If the second partial derivatives of } f \text{ are continuous throughout an open disk centered at } (a,b) \text{. Let } D(x,y) = f_{xx}(x,y)f_{yy}(x,y) - (f_{xy}(x,y))^{2} \text{.}\\\\
\text{If } D(a,b) > 0 \text{ and } f_{xx}(a,b) < 0 \text{, there exists a local max at } (a,b) \text{.}\\
\text{If } D(a,b) > 0 \text{ and } f_{xx}(a,b) < 0 \text{, there exists a local min at } (a,b) \text{.}\\
\text{If } D(a,b) < 0 \text{, there exists a saddle point at }(a,b) \text{.}\\
\text{If } D(a,b) = 0 \text{ the test is inconclusive.}
\]
## Lagrange Multipliers
-----------------------
Theorem:
\[
\text{Let } f \text{ be a differentiable function in } R^2 \text{ that contains curve } C \text{ given by } g(x,y) = 0. \text{ Assume } f \text{ has a local extrema on } C \text{ at point } P(a,b). \text{ Then } \nabla f(a,b) \text{ is orthogonal to the tangent line of } C \text{ at } P. \text{ Assuming } \nabla g(a,b) \neq 0, \text{ then there is a real number } \lambda \text{, or lagrange multiplier, such that } \nabla f(a,b) = \lambda \nabla g(a,b).
\]
To find absolute extremas using lagrange multipliers:
1. Find the gradient of \(f\)
2. Find the gradient of \(g\)
3. Set \(\nabla f(x,y) = \lambda \nabla g(x,y)\)
4. Solve the system for \(x\) and \(y\) of \(\nabla f(x,y) = \lambda \nabla g(x,y)\) and \(g(x,y) = 0\).
- Determine \(x\) and \(y\) for each case of \(\lambda\).
5. Evaluate the points \((x,y)\) you've found in \(f(x,y)\). The largest value is the absolute maximum. The smallest value is the absolute minimum.

Binary file not shown.

Binary file not shown.

149
content/cpp/basics.md Normal file
View File

@@ -0,0 +1,149 @@
+++
date = '2026-02-27T23:57:42-06:00'
draft = false
title = 'Basics'
layout = 'chapter'
type = 'book'
tags = 'cpp'
chapterno = 1
+++
## I. Introduction
A C++ program generally consists of preprocessor directives and the main function.
A preprocessor directive tells the C++ preprocessor what to do before compiling. You can use this to include files, create macros, and determine compiling based on conditions. For example, include a file using `#include` This will include the iostream file from the C++ standard library.
The main function looks like:
```c++
int main() {
std::cout << "Hello world" << '\n';
return 0;
}
```
The `int main() {` is the declaration of the main function denoting it returns type int. `return 0;` is the return statement for the function. It is returning the integer 0. This tells the operating system, OK Quit the program safely.
## II. Variables
A variable lets you allocate some memory in the computer and use it to store values. You can also recall the values for later. Variables contain a memory address and an identifier. An identifier can be \*almost\* anything you wish it to be.
Variables naming rules:
- Cannot start with a number.
- Can only contain alphanumeric characters and underscores.
- Cannot contain any reserved keywords [(see here)](https://en.cppreference.com/w/cpp/keyword.html).
- If starting with an underscore, it can only start with one.
All variables have denoted types and they refer to what kind of variable it is. All variables also have a bit size and this denotes the range of values that can be stored.
Variable types:
- Integers:
- short int:
- Size: 2 bytes.
- Range: -32,768 to 32,767
- int:
- Size: 4 bytes.
- Range: -2 billion to 2 billion
- short:
- Size: 8 bytes.
- Floats:
- float:
- Size: 4 bytes.
- 6 significant figures.
- double:
- Size: 8 bytes.
- 15 significant figures.
- long double:
- Size: 16 bytes.
- 19 significant figures.
- Character:
- char
- Stores an integer value representative of an "ASCII" character.
- Size: 1 byte.
- String:
- string
- Stores an indexable array of characters.
- Variable creation: `std::string identifier = "string literal";`
- Boolean:
- bool
- Stores an integer value of 0 or 1 representative of false or true respectively.
- Size: 1 byte
Variables are always declared before they are initialized. This means you must determine the type and the identifier before you store any values into it.
```c++
int main() {
int a; // Declaration
a = 1; // Initialization
int b = 2; // Declaration then initialization
}
```
Constant types are variables identified by `const` in their type definition. These are not allowed to be modified after they are declared and must be initialized at declaration.
## III. Operators
Just like in mathematics, operators let you perform functions on elements. We'll start by viewing arithmetic operators and assignment. The assignment operator, denoted by `=` allows you to assign values to a variable. Assigning a variable with a value of a different type will give you a warning. This can be solved by casting the value being assigned to the same type as your variable: `static_cast(var)`. Assignment also works from right to left. Values on the right of the assignment operator get assigned to the identifier on the left of the assignment operator. Arithmetic operators allow you to do operations such as addition, subtraction, multiplication, division, and remainder division. When dividing with numbers, it is important to know the type of numbers you are dividing. Division between integers will only return a whole number. For example `5 / 2 = 2`. Suppose the 5 was a floating point type then, `5.0 / 2 = 2.5`. It is important to know what types you are using when performing division. When wanting to perform division and only return the remainder, you can use the modulus operator. For example, `5 / 2 = 2` whereas `5 % 2 = 1`. 2 is the quotient and 1 is the remainder.
- \+ Addition
- \- Subtraction
- \* Multiplication
- / Division
- % Modulus
There are also ways to quickly perform arithmetic operations using "fast operators".
- Post increment/decrement:
- This will return the current value and then perform the operation.
- `x++`
- `x--`
- Pre increment/decrement:
- This will perform the operation, then return the current value.
- `++x`
- `--x`
The following is short for `x = x (operation) y`:
- `x += y`
- `x -= y`
- `x *= y`
- `x /= y`
- `x %= y`
Next we'll approach the relational and logical operators. These allow you to evaluate comparisons between two or more variables.
Relational Operators:
- Less than: <
- Greater than: >
- Less than or equal to: <=
- Greater than or equal to: >=
- Is equal to: ==
- Is not equal to: !=
Logical Operators:
- AND: &&
- OR: ||
- NOT: !
When using multiple operators, it is important to know that operators have a precedence, just like in mathematics. Operators with the same precedence are evaluated in the statement from left to right.
|Precedence|Operator(s)|
|----------|-----------|
|1 |Parenthesis|
|2 |x++, x-- |
|3 |++x, --x |
|4 |! |
|5 |* / % |
|6 |+ - |
|7 |< > <= >= |
|8 |== != |
|9 |&& |
|10 |\|\| |
|11 |= |

149
content/cpp/control_flow.md Normal file
View File

@@ -0,0 +1,149 @@
+++
date = '2026-02-27T23:57:42-06:00'
draft = true
title = 'Control Flow'
layout = 'chapter'
type = 'book'
tags = 'cpp'
chapterno = 2
+++
## I. Introduction
A C++ program generally consists of preprocessor directives and the main function.
A preprocessor directive tells the C++ preprocessor what to do before compiling. You can use this to include files, create macros, and determine compiling based on conditions. For example, include a file using `#include` This will include the iostream file from the C++ standard library.
The main function looks like:
```c++
int main() {
std::cout << "Hello world" << '\n';
return 0;
}
```
The `int main() {` is the declaration of the main function denoting it returns type int. `return 0;` is the return statement for the function. It is returning the integer 0. This tells the operating system, OK Quit the program safely.
## II. Variables
A variable lets you allocate some memory in the computer and use it to store values. You can also recall the values for later. Variables contain a memory address and an identifier. An identifier can be \*almost\* anything you wish it to be.
Variables naming rules:
- Cannot start with a number.
- Can only contain alphanumeric characters and underscores.
- Cannot contain any reserved keywords [(see here)](https://en.cppreference.com/w/cpp/keyword.html).
- If starting with an underscore, it can only start with one.
All variables have denoted types and they refer to what kind of variable it is. All variables also have a bit size and this denotes the range of values that can be stored.
Variable types:
- Integers:
- short int:
- Size: 2 bytes.
- Range: -32,768 to 32,767
- int:
- Size: 4 bytes.
- Range: -2 billion to 2 billion
- short:
- Size: 8 bytes.
- Floats:
- float:
- Size: 4 bytes.
- 6 significant figures.
- double:
- Size: 8 bytes.
- 15 significant figures.
- long double:
- Size: 16 bytes.
- 19 significant figures.
- Character:
- char
- Stores an integer value representative of an "ASCII" character.
- Size: 1 byte.
- String:
- string
- Stores an indexable array of characters.
- Variable creation: `std::string identifier = "string literal";`
- Boolean:
- bool
- Stores an integer value of 0 or 1 representative of false or true respectively.
- Size: 1 byte
Variables are always declared before they are initialized. This means you must determine the type and the identifier before you store any values into it.
```c++
int main() {
int a; // Declaration
a = 1; // Initialization
int b = 2; // Declaration then initialization
}
```
Constant types are variables identified by `const` in their type definition. These are not allowed to be modified after they are declared and must be initialized at declaration.
## III. Operators
Just like in mathematics, operators let you perform functions on elements. We'll start by viewing arithmetic operators and assignment. The assignment operator, denoted by `=` allows you to assign values to a variable. Assigning a variable with a value of a different type will give you a warning. This can be solved by casting the value being assigned to the same type as your variable: `static_cast(var)`. Assignment also works from right to left. Values on the right of the assignment operator get assigned to the identifier on the left of the assignment operator. Arithmetic operators allow you to do operations such as addition, subtraction, multiplication, division, and remainder division. When dividing with numbers, it is important to know the type of numbers you are dividing. Division between integers will only return a whole number. For example `5 / 2 = 2`. Suppose the 5 was a floating point type then, `5.0 / 2 = 2.5`. It is important to know what types you are using when performing division. When wanting to perform division and only return the remainder, you can use the modulus operator. For example, `5 / 2 = 2` whereas `5 % 2 = 1`. 2 is the quotient and 1 is the remainder.
- \+ Addition
- \- Subtraction
- \* Multiplication
- / Division
- % Modulus
There are also ways to quickly perform arithmetic operations using "fast operators".
- Post increment/decrement:
- This will return the current value and then perform the operation.
- `x++`
- `x--`
- Pre increment/decrement:
- This will perform the operation, then return the current value.
- `++x`
- `--x`
The following is short for `x = x (operation) y`:
- `x += y`
- `x -= y`
- `x *= y`
- `x /= y`
- `x %= y`
Next we'll approach the relational and logical operators. These allow you to evaluate comparisons between two or more variables.
Relational Operators:
- Less than: <
- Greater than: >
- Less than or equal to: <=
- Greater than or equal to: >=
- Is equal to: ==
- Is not equal to: !=
Logical Operators:
- AND: &&
- OR: ||
- NOT: !
When using multiple operators, it is important to know that operators have a precedence, just like in mathematics. Operators with the same precedence are evaluated in the statement from left to right.
|Precedence|Operator(s)|
|----------|-----------|
|1 |Parenthesis|
|2 |x++, x-- |
|3 |++x, --x |
|4 |! |
|5 |* / % |
|6 |+ - |
|7 |< > <= >= |
|8 |== != |
|9 |&& |
|10 |\|\| |
|11 |= |

11
content/cpp/frontcover.md Normal file
View File

@@ -0,0 +1,11 @@
+++
date = '2026-02-27T22:44:20-06:00'
draft = false
title = 'C++ Notes'
type = 'book'
layout = 'frontcover'
tags = 'cpp'
chapterno = 0
+++
Welcome to my C++ Notes. Here you will find a list of chapters to browse.

108
content/cpp/functions.md Normal file
View File

@@ -0,0 +1,108 @@
+++
date = '2026-02-27T23:57:42-06:00'
draft = false
title = 'Functions'
layout = 'chapter'
type = 'book'
tags = 'cpp'
chapterno = 3
+++
## Documentation practice
It is a good idea to include comments along with the functions you create and should only be put within the function prototype. They should include:
- A brief description of its purpose:
- Precondition:
- The conditions that are required in order for the function to work properly.
- Postcondition:
- Only include if the final result of your function is difficult to understand by reading the code.
Make sure when creating comments, do not state the obvious. They clutter your code and make it more difficult to read your code. Only include comments to things that are complex or difficult to understand.
Example:
```c++
// Description: Returns the square of a number.
// Pre: Size of x must be less than size of int when squared.
int square(const int x);
int square(int x) {
return x * x;
}
```
Function abstraction is the ability to make a function easy to use without understanding exactly how the function works line by line. This makes it easy for other people to use your code faster. It is a good practice to make your code easy to use for other people.
## Default arguments
--------------------
Suppose you want a function to occassionaly not have values for parameters explicitly define, you can set a default value for your parameters within your function.
```c++
void average(float num1 = 3, float num2 = 3, float num3 = 3);
```
In this example, the default parameters were create in the function prototype. Suppose you call the function by `average();`, then without passing and values, num1, num2, and num3 were all initialized with 3 as we have define in the prototype. Default arguments also work with just one parameter. You can set whatever parameter you want to have a default argument. Also, as long as the default argument is defined in the prototype, you should not include it in the definition. __Keep in mind, default arguments must be at the end of the parameter list.__ Also __you cannot use default arguments with non-constant pass by reference types__.
## Function overloading
-----------------------
Function overloading lets you use functions with the same name but contain different parameters.
```c++
void display(string message) {
std::cout << message << '\n';
}
void display(int data) {
std::cout << data << '\n';
}
```
Having both of these definitions is an example of function overloading. The implementation of this is quite simple.
Rules for modifying function signatures:
1. # of parameters
2. Parameter data types
3. Pass by value / Pass by reference
- __Does not change signature__
4. Addition of const modifier
- __Only changes signature when using Pass-by-reference__
5. Introducing default arguments
- __Does not change signature_
6. Modifying return types
## Static Variables
Appending the static type to a variable declares to the compiler to only initialize the variable once. Usually, every time the function is called, the local variable gets created. The static keyword stops this behavior.

View File

@@ -0,0 +1,9 @@
+++
date = '2026-03-05T18:36:18-06:00'
draft = false
title = 'Game Theory Notes'
layout = 'frontcover'
type = 'book'
tags = 'gametheory'
chapterno = 0
+++

View File

@@ -0,0 +1,9 @@
+++
date = '2026-03-02T18:38:16-06:00'
draft = false
title = 'Linux Notes'
layout = 'frontcover'
type = 'book'
tags = 'linux'
chapterno = 0
+++

View File

@@ -0,0 +1,16 @@
+++
date = '2026-03-02T18:39:17-06:00'
draft = false
title = 'Enable oddjob-mkhomedir'
layout = 'chapter'
type = 'book'
tags = 'linux'
chapterno = 1
+++
This is for RHEL based distros, specifically Fedora 43+:
1. Check if `oddjob` and `oddjob-mkhomedir` is installed.
2. Run as root: `authselect enable-feature with-mkhomedir`
3. Enable oddjobd. Run as root: `systemctl enable --now oddjobd.service`

View File

@@ -0,0 +1,9 @@
+++
date = '2026-03-02T18:38:40-06:00'
draft = true
title = 'Polkit Ldap'
layout = ''
type = 'book'
tags = ''
chapterno = 0
+++

9
content/linux/vim.md Normal file
View File

@@ -0,0 +1,9 @@
+++
date = '2026-03-02T18:39:49-06:00'
draft = true
title = 'Vim'
layout = ''
type = 'book'
tags = ''
chapterno = 0
+++

View File

@@ -0,0 +1,9 @@
+++
date = '2026-02-28T22:16:48-06:00'
draft = false
title = 'Physics Notes'
layout = 'frontcover'
type = 'book'
tags = 'physics'
chapterno = 0
+++

3
debug.sh Normal file
View File

@@ -0,0 +1,3 @@
#!/bin/bash
hugo server -D

18
hugo.toml Normal file
View File

@@ -0,0 +1,18 @@
baseURL = 'https://lukerufkahr.com'
languageCode = 'en-us'
title = 'My New Hugo Site'
[taxonomies]
tag = 'tags'
chapterno = 'chapterno'
[markup]
[markup.highlight]
style = 'gruvbox-light'
[markup.goldmark]
[markup.goldmark.extensions]
[markup.goldmark.extensions.passthrough]
enable = true
[markup.goldmark.extensions.passthrough.delimiters]
block = [['\[', '\]'], ['$$', '$$']]
inline = [['\(', '\)'], ['$', '$']]
[params]
math = true

0
i18n/empty Normal file
View File

View File

@@ -1,9 +0,0 @@
<!DOCTYPE html>
<body>
<h1>lukerufkahr.com</h1>
<ul>
<li>Physics</li>
<li>Circuits</li>
<li><a href="notes/cpp.html">C++</a></li>
</ul>
</body>

View File

@@ -0,0 +1,21 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
{{ if .Param "math" }}
{{ partialCached "math.html" . }}
{{ end }}
<title></title>
</head>
<body style="width: 60%; margin: 0 auto;">
<header>{{ partial "header.html" }}</header>
<main>
{{ block "main" . }}
{{ end }}
</main>
<footer>{{ partial "footer.html" }}</footer>
</body>
</html>

View File

@@ -0,0 +1 @@
<small>you've reached the end of the page. have a goOoOoOod day.</small>

View File

@@ -0,0 +1 @@
<a href="https://lukerufkahr.com">home</a>

View File

@@ -0,0 +1,26 @@
<script type="text/javascript" id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@4/tex-mml-chtml.js"></script>
<script>
MathJax = {
tex: {
displayMath: [['\\[', '\\]'], ['$$', '$$']], // block
inlineMath: [['\\(', '\\)'], ['$', '$']] // inline
},
loader:{
load: ['ui/safe']
},
output: {
displayAlign: 'left',
displayIndent: '0.25in',
displayOverflow: 'linebreak'
},
linebreaks: {
inline: true,
width: '100%',
lineleading: '0.2',
LinebreakVisistor: '-'
}
};
</script>

View File

@@ -0,0 +1,7 @@
{{ $books := where .Site.AllPages "Layout" "frontcover" }}
Books:
<ul>
{{ range sort $books "Params.chapterno" "asc" }}
<li><a href="{{ .Permalink }}">{{ .Title }}</a></li>
{{ end }}
</ul>

View File

@@ -0,0 +1,5 @@
{{ define "main" }}
<h1>{{.Title}}</h1>
{{ .TableOfContents }}
{{ .Content }}
{{ end }}

View File

@@ -0,0 +1,10 @@
{{ define "main" }}
<h1>{{ .Title }}</h1>
{{ .Content }}
{{ $chapters := where .Site.AllPages "Params.tags" .Params.tags }}
{{ range sort $chapters "Params.chapterno" "asc" }}
{{ if gt .Params.chapterno 0 }}
<li><a href="{{ .Permalink }}">{{ .Params.chapterno }}. {{ .Title }}</a></li>
{{ end }}
{{ end }}
{{ end }}

3
layouts/index.html Normal file
View File

@@ -0,0 +1,3 @@
{{ define "main" }}
{{ .Content }}
{{ end }}

View File

@@ -1,154 +0,0 @@
<!DOCTYPE html>
<head>
<style>
body {
margin:0;
padding:0;
}
main {
margin:2em;
}
header {
display:block;
width: 100%;
background-color:black;
padding:1em;
}
header * {
color:white;
display:inline;
padding-left:1em;
}
code, pre {
whitespace: normal;
}
.cblock {
padding-left: 1em;
padding-right: 1em;
display: inline-block;
margin-left: 5em;
background-color:lightgray;
}
</style>
</head>
<body>
<header>
<span style="font-size: 32px;">Lucas Rufkahr</span>
<a href="https://lukerufkahr.com">Home</a>
<a href="https://lukerufkahr.com/notes.html">Notes</a>
<a href="https://lukerufkahr.com/fun_stuff.html">Fun</a>
</header>
<main>
<h1>C++ Notes</h1>
<h2>ToC</h2>
<ul>
<li><a href="#basics">Basics</a></li>
<ul>
<li><a href="#basics-introduction">Introduction</a></li>
<li><a href="#basics-variables">Variables</a>
<li><a href="#basics-operators">Operators</a>
</ul>
<li><a href="#control_flow">Control Flow</a></li>
</ul>
<hr>
<h2 id="basics">Basics</h2>
<h3 id="basics-introduction">I. Introduction</h3>
<p>
A C++ program generally consists of preprocessor directives and the main function.<br>
<br>
A preprocessor directive tells the C++ preprocessor what to do before compiling. You can use this to include files, create macros, and determine compiling based on conditions. For example, include a file using <code>#include <iostream></code> This will include the iostream file from the C++ standard library.<br>
<br>
The main function looks like:
<code class="cblock"><pre>int main() {
<!-----> std::cout << "Hello world" << '\n';
<!-----> return 0;
<!----->}</pre></code>
The <code>int main() {</code> is the declaration of the main function denoting it returns type int. <code>return 0;</code> is the return statement for the function. It is returning the integer 0. This tells the operating system, OK Quit the program safely.
</p>
<h3 id="basics-variables">II. Variables</h3>
<p>
A variable lets you allocate some memory in the computer and use it to store values. You can also recall the values for later. Variables contain a memory address and an identifier. An identifier can be *almost* anything you wish it to be.<br>
<br>
Variables naming rules:
<ul>
<li>Cannot start with a number.</li>
<li>Can only contain alphanumeric characters and underscores.</li>
<li>Cannot contain any reserved keywords <a href="https://en.cppreference.com/w/cpp/keyword.html">(see here)</a>.
<li>If starting with an underscore, it can only start with one.</li>
</ul>
All variables have denoted types and they refer to what kind of variable it is. All variables also have a bit size and this denotes the range of values that can be stored.<br>
<br>
Variable types:
<ul>
<li>Integers:</li>
<ul>
<li>short int:</li>
<ul>
<li>Size: 2 bytes.</li>
<li>Range: -32,768 to 32,767</li>
</ul>
<li>int:</li>
<ul>
<li>Size: 4 bytes.</li>
<li>Range: -2 billion to 2 billion</li>
</ul>
<li>short:</li>
<ul>
<li>Size: 8 bytes.</li>
</ul>
</ul>
<li>Floats:</li>
<ul>
<li>float:</li>
<ul>
<li>Size: 4 bytes.</li>
<li>6 significant figures.</li>
</ul>
<li>double:</li>
<ul>
<li>Size: 8 bytes.</li>
<li>15 significant figures.</li>
</ul>
<li>long double:</li>
<ul>
<li>Size: 16 bytes.</li>
<li>19 significant figures.</li>
</ul>
</ul>
<li>Character:</li>
<ul>
<li>Type: char</li>
Stores an integer value representative of an "ASCII" character.
<li>Size: 1 byte.</li>
</ul>
<li>String:</li>
<ul>
Stores an indexable array of characters.
<li>Usage: <code>#include <string></code>
<li>Variable creation: <code>std::string identifier = "string literal";</code></li>
</ul>
<li>Boolean:</li>
<ul>
Stores an integer value of 0 or 1 representative of false or true respectively.
<li>Type: bool</li>
<li>Size: 1 byte</li>
</ul>
</ul>
<br>
Variables are always declared before they are initialized. This means you must determine the type and the identifier before you store any values into it.<br>
<br>
<code class="cblock"><pre>int main() {
<!-----> int a; // Declaration
<!-----> a = 1; // Initialization
<!-----> int b = 2; // Declaration then initialization
<!----->}</pre></code><br>
<br>
Constant types are variables identified by <code>const</code> in their type definition. These are not allowed to be modified after they are declared and must be initialized at declaration.
</p>
<h3 id="#basics-operators">Operators</h3>
<h2 id="control_flow">Control Flow</h2>
</main>
</body>

321
placeholder.md Normal file
View File

@@ -0,0 +1,321 @@
C++ Notes
=========
ToC
---
* [Basics](#basics)
* [Introduction](#basics-introduction)
* [Variables](#basics-variables)
* [Operators](#basics-operators)
* [Control Flow](#control_flow)
* [Decision Branching](#control_flow-branching)
* [Loops](#control_flow-loops)
* [Switches](#control_flow-switches)
* [Ternary Operator](#control_flow-ternary)
* [Other Topics](#other)
* [String Manipulation](#other_string-manipulation)
* * *
Basics
------
### I. Introduction
A C++ program generally consists of preprocessor directives and the main function.
A preprocessor directive tells the C++ preprocessor what to do before compiling. You can use this to include files, create macros, and determine compiling based on conditions. For example, include a file using `#include` This will include the iostream file from the C++ standard library.
The main function looks like:
int main() {
std::cout << "Hello world" << '\n';
return 0;
}
The `int main() {` is the declaration of the main function denoting it returns type int. `return 0;` is the return statement for the function. It is returning the integer 0. This tells the operating system, OK Quit the program safely.
### II. Variables
A variable lets you allocate some memory in the computer and use it to store values. You can also recall the values for later. Variables contain a memory address and an identifier. An identifier can be \*almost\* anything you wish it to be.
Variables naming rules:
* Cannot start with a number.
* Can only contain alphanumeric characters and underscores.
* Cannot contain any reserved keywords [(see here)](https://en.cppreference.com/w/cpp/keyword.html).
* If starting with an underscore, it can only start with one.
All variables have denoted types and they refer to what kind of variable it is. All variables also have a bit size and this denotes the range of values that can be stored.
Variable types:
* Integers:
* short int:
* Size: 2 bytes.
* Range: -32,768 to 32,767
* int:
* Size: 4 bytes.
* Range: -2 billion to 2 billion
* short:
* Size: 8 bytes.
* Floats:
* float:
* Size: 4 bytes.
* 6 significant figures.
* double:
* Size: 8 bytes.
* 15 significant figures.
* long double:
* Size: 16 bytes.
* 19 significant figures.
* Character:
* Type: char
Stores an integer value representative of an "ASCII" character.* Size: 1 byte.
* String:
Stores an indexable array of characters.* Usage: `#include`
* Variable creation: `std::string identifier = "string literal";`
* Boolean:
Stores an integer value of 0 or 1 representative of false or true respectively.* Type: bool
* Size: 1 byte
Variables are always declared before they are initialized. This means you must determine the type and the identifier before you store any values into it.
` int main() { int a; // Declaration a = 1; // Initialization int b = 2; // Declaration then initialization } `
Constant types are variables identified by `const` in their type definition. These are not allowed to be modified after they are declared and must be initialized at declaration.
### III. Operators
Just like in mathematics, operators let you perform functions on elements. We'll start by viewing arithmetic operators and assignment.
The assignment operator, denoted by `=` allows you to assign values to a variable. Assigning a variable with a value of a different type will give you a warning. This can be solved by casting the value being assigned to the same type as your variable: `static_cast(var)`. Assignment also works from right to left. Values on the right of the assignment operator get assigned to the identifier on the left of the assignment operator.
Arithmetic operators allow you to do operations such as addition, subtraction, multiplication, division, and remainder division.
When dividing with numbers, it is important to know the type of numbers you are dividing. Division between integers will only return a whole number. For example `5 / 2 = 2`. Suppose the 5 was a floating point type then, `5.0 / 2 = 2.5`. It is important to know what types you are using when performing division.
When wanting to perform division and only return the remainder, you can use the modulus operator. For example, `5 / 2 = 2` whereas `5 % 2 = 1`. 2 is the quotient and 1 is the remainder.
* \+ Addition
* \- Subtraction
* \* Multiplication
* / Division
* % Modulus
There are also ways to quickly perform arithmetic operations using "fast operators".
* Post increment/decrement:
This will return the current value and then perform the operation.
`x++`
`x--`
* Pre increment/decrement:
This will perform the operation, then return the current value.
`++x`
`--x`
The following is short for `x = x (operation) y`:* `x += y`
* `x -= y`
* `x *= y`
* `x /= y`
* `x %= y`
Next we'll approach the relational and logical operators. These allow you to evaluate comparisons between two or more variables.
Relational Operators
* Less than: <
* Greater than: >
* Less than or equal to: <=
* Greater than or equal to: >=
* Is equal to: ==
* Is not equal to: !=
Logical Operators
* AND: &&
* OR: ||
* NOT: !
When using multiple operators, it is important to know that operators have a precedence, just like in mathematics.
Operators with the same precedence are evaluated in the statement from left to right.
1st
Last
(a)
x++, x++
++x, --x
!
\* / %
\+ -
< > <= >=
\== !=
&&
||
\=
Control Flow
------------
### I. Decision Branching
An `if` statement will execute instructions if the condition evaluates to true. You can remember this as if something is true, then my program will do this. For example:
int main() {
int x = 1;
if (x == 1) {
std::cout << x << " is equal to 1.\n";
}
return 0;
}
will execute "1 is equal to 1".
An `if-else` statement will execute instructions if the condition is true and execute different instructions when the condition is false.
` int main() { int x = 1; if (x == 1) { std::cout << x << " is equal to 1.\n"; } else { std::cout << x << " is not equal to 1.\n"; } return 0; } `
One thing to note about these types of control statements, is that they can be nested to create a decision branch. A branch, like of a tree, splits off into many smaller branches. The more nested if-else statements you have, the more and more branches you add to your decision tree.
### II. Loops
Loops are good when you need to repeat a segment of instruction multiple times. There are a few different types of loops to be aware of.
* While loop
* Do-While loop
* For loop
The while loop is used when the number of iterations is based on a condition that can change each time the program is run. Before the section of code within the loop body executes, first the condition must be checked. If the condition evaluates to false, the loop does not execute, similar to the if statement.
` int main() { int x = true; while (x == true) { std::cout << "Hello!"; } } `
This while loop will run infinitively many times because x will always equal true. There is no where in this program that the value of x changes so the loop will never leave the brackets of the while loop.
The do-while loop will always evaluate once. This is because, unlike the while loop, the condition is checked after the main body executes.
` int main() { int x = true; do { std::cout << "Hello!"; } while (x == false); } `
Note the slight change to the condition. This loop will repeat when x is false though as you can see, x is initialized to be true. However, unlike the while loop previously, this will output just one "Hello". You can see that the condition is placed after the `do { .. }` so the condition gets checked after it executes.
The final type of loop is the for loop. This is used when the number of iterations of the loop is determine before the loop starts. You should not change the number of iterations after you create the loop.
` int main() { int x = true; for (int i = 0; i < 10; i++) { std::cout << "Hello!"; } } `
You can see here, the for loop starts at `i = 0`, checks if `i < 10`, then outputs `Hello!`. Then `i++` executes and i increases by 1. Then the loop repeats. The loop checks if `i < 10`. i is 1 now so this is true and the program outputs `Hello!`. This repeats until `i < 10` is false which is when `i = 10`. Pretty simple stuff.
Now suppose you want to leave a loop before the condition is false or skip an iteration quickly. Then you can use the `break` and `continue` statements. `break` will BREAK out of a loop causing is to cease executing. `continue` will SKIP everthing after the continue and start back at the top of the loop.
### III. Switch
Suppose you have a large array of if-else statements.
if (a == 1) {
...
} else if (a == 2) {
...
} else if (a == 3) {
...
} else if (a == 4) {
...
} else if (a == 5) {
...
} else if (a == 6) {
...
} else if (a == 7) {
...
} else { ... }
Instead of writing that, you could've used a switch:
` switch (a) { case 1: ... break; case 2: ... break; case 3: ... break; case 4: ... break; case 5: ... break; case 6: ... break; case 7: ... break; default: ... break; } `
One caveat is that the case must be a literal value. It cannot be another value. Another is that a `break;` statement must be added to the end of every case or the statements will waterfall down from the case they started at to the next break statement. This is a feature of switches.
### IV. Ternary Operator
The ternary operator lets you condense a simple if-else statement into one line.
x = (a > b) ? 1 : 0;
This means that if a is greater than b, assign x with 1. If a is not greater than b, assign x with 0. The ternary operator however needs the values in the if and else part to be of the same type. If they are not, the program will fail to compile.
Functions
---------
### I. Basics
A function is a wrapper to easily reuse code and improve readability of your program. The function signature contains the return type, the identifier of the function, and the parameters that the function requires. The function contains statements within the curly braces. Finally, the function returns a value which has a type indicated in the function signature. Proper functions also have one intended use. If a function contains more than one use, it is a good idea to split them up.
type name (parameters) {...}
Functions must be defined before they are called. That is, the definition must come before any reference to using the function. A function call is done by referencing the name of the function as a statement. For example `my_function(1,2,3);` is a call to `my_function(int a, int b, int c) {...}` with the parameter values `a = 1, b = 2, c = 3`.
A function which does not return anything has the type of `void`. When using a void type for a function, it is okay to omit the return statement at the end of the function. In other words, when using a void type, the return statement is optional.
Functions are also essential to organized code. It can also save you time because you no longer need to rewrite or copy large blocks of code that may need to be re-used. Instead, just call the function.
### II. Function Types
In c++, there are three different types of function parameters.
* Pass by value
* The data that is included in the function parameter is copied from the value of the variable that is in the argument. This creates an entirely new variable with the exact same data as the variable in the parameter. This new variable has only the scope of the function it is used in. When the function exists, this variable is destroyed.
* Pass by reference
* The address of the variable is directly associated with the variables for the local scope. That is, these local scope variables now hve access to the variables outside of the scope. This is done by using the ampersand character: `void my_func(int &var) {...}`. Essentially, these new variables contain no new data and do not take up any more memory that was already there. No matter is created, only another name for a variable which is removed after the function completes execution. The pass-by-reference parameters are called reference parameters and the arguments are called reference arguments.
* Constant parameters
* Constant types of parameters contain the `const` type for the parameters. The constant parameter can be either pass-by-value or a pass-by-reference type as well.
#### Pass by value:
Other Topics
------------
### String Manipulation
...

0
static/empty Normal file
View File

0
themes/empty Normal file
View File