2 "cells": [
3 {
4 "cell_type": "markdown",
5 "id": "dt-0",
6 "metadata": {},
9ff4e5bRestructure demo into a full guided tour with OOP and namespacesJeremy Magland 7 "source": "# Data types and operators\n\nA tour of numbl's scalar types and operators."
9 {
10 "cell_type": "markdown",
11 "id": "dt-1",
12 "metadata": {},
13 "source": "## Numbers and arithmetic"
14 },
15 {
16 "cell_type": "code",
17 "id": "dt-2",
18 "metadata": {},
19 "execution_count": null,
20 "outputs": [],
21 "source": "x = 3.5;\ny = 2;\n[x + y, x - y, x * y, x / y]\nx ^ y\nmod(7, 3)"
22 },
23 {
24 "cell_type": "markdown",
25 "id": "dt-3",
26 "metadata": {},
27 "source": "## Logical values and comparisons"
28 },
29 {
30 "cell_type": "code",
9ff4e5bRestructure demo into a full guided tour with OOP and namespacesJeremy Magland 31 "id": "dt-4",
33 "execution_count": null,
34 "outputs": [],
35 "source": "v = [1 2 3 4 5];\nv > 2\nv == 3\nany(v > 4)\nall(v > 0)"
36 },
37 {
38 "cell_type": "code",
9ff4e5bRestructure demo into a full guided tour with OOP and namespacesJeremy Magland 39 "id": "dt-5",
41 "execution_count": null,
42 "outputs": [],
43 "source": "t = true; f = false;\n[t && f, t || f, xor(t, f), ~t]"
44 },
45 {
46 "cell_type": "markdown",
9ff4e5bRestructure demo into a full guided tour with OOP and namespacesJeremy Magland 47 "id": "dt-6",
49 "source": "## Complex numbers"
50 },
51 {
52 "cell_type": "code",
9ff4e5bRestructure demo into a full guided tour with OOP and namespacesJeremy Magland 53 "id": "dt-7",
55 "execution_count": null,
56 "outputs": [],
57 "source": "z = 3 + 4i;\nabs(z)\nangle(z)\n[real(z), imag(z)]\nconj(z)"
58 },
59 {
60 "cell_type": "markdown",
9ff4e5bRestructure demo into a full guided tour with OOP and namespacesJeremy Magland 61 "id": "dt-8",
9ff4e5bRestructure demo into a full guided tour with OOP and namespacesJeremy Magland 63 "source": "## Constants, special values, and rounding"
65 {
66 "cell_type": "code",
9ff4e5bRestructure demo into a full guided tour with OOP and namespacesJeremy Magland 67 "id": "dt-9",
69 "execution_count": null,
70 "outputs": [],
9ff4e5bRestructure demo into a full guided tour with OOP and namespacesJeremy Magland 71 "source": "[pi, exp(1), eps]\n[1/0, -1/0, 0/0]\n[isnan(0/0), isinf(1/0)]"
73 {
74 "cell_type": "code",
9ff4e5bRestructure demo into a full guided tour with OOP and namespacesJeremy Magland 75 "id": "dt-10",
77 "execution_count": null,
78 "outputs": [],
79 "source": "[round(2.5), floor(-2.3), ceil(2.1), fix(-2.7), sign(-3)]"
80 }
81 ],
82 "metadata": {
83 "kernelspec": {
84 "display_name": "numbl (MATLAB syntax)",
85 "language": "numbl",
86 "name": "numbl"
87 },
88 "language_info": {
89 "codemirror_mode": "octave",
90 "file_extension": ".m",
91 "mimetype": "text/x-octave",
92 "name": "numbl",
93 "nbconvert_exporter": "script",
94 "pygments_lexer": "matlab"
95 }
96 },
97 "nbformat": 4,
98 "nbformat_minor": 5
99}