Skip to content

Commit

Permalink
doc: fix indices syntax on tensors (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
martinjrobins authored Jan 3, 2025
1 parent 0181574 commit b3b532f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 19 deletions.
34 changes: 17 additions & 17 deletions book/src/tensors.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ This is useful when defining higher dimensional tensors, such as matrices. For e

```
A_ij {
(0:2, 0:3) = 1.0,
(0:2, 0:3): 1.0,
}
```

Expand All @@ -59,18 +59,18 @@ Here is another example of a 4x2 matrix \\( B \\) with rows 0 to 2 set to `1.0`

```
A_ij {
(0:2, 0:3) = 1.0,
(3:4, 0:3) = 2.0,
(0:2, 0:3): 1.0,
(3:4, 0:3): 2.0,
}
```

For specifying a single index, you can simply write the index number without the colon, for example to define a 3x3 identity matrix $I$:

```
I_ij {
(0, 0) = 1.0,
(1, 1) = 1.0,
(2, 2) = 1.0,
(0, 0): 1.0,
(1, 1): 1.0,
(2, 2): 1.0,
}
```

Expand All @@ -83,7 +83,7 @@ Finally, you can also use the `..` operator to specify a *diagonal* range of ind

```
D_ij {
(0..2, 0..2) = 1.0,
(0..2, 0..2): 1.0,
}
```

Expand All @@ -93,9 +93,9 @@ We can automatically define a sparse matrix \\( B \\) by simply specifying the n

```
B_ij {
(0, 0) = 1.0,
(0, 1) = 2.0,
(1, 1) = 3.0,
(0, 0): 1.0,
(0, 1): 2.0,
(1, 1): 3.0,
}
```

Expand All @@ -104,20 +104,20 @@ We can force the compiler to use a dense representation by specifying the zeros

```
B_ij {
(0, 0) = 1.0,
(0, 1) = 2.0,
(1, 0) = 0.0,
(1, 1) = 3.0,
(0, 0): 1.0,
(0, 1): 2.0,
(1, 0): 0.0,
(1, 1): 3.0,
}
```

As well as specifying a sparse matrix, we can also define a diagonal matrix by specifying the diagonal elements:

```
D_ij {
(0, 0) = 1.0,
(1, 1) = 2.0,
(2, 2) = 3.0,
(0, 0): 1.0,
(1, 1): 2.0,
(2, 2): 3.0,
}
```

Expand Down
2 changes: 0 additions & 2 deletions src/execution/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,6 @@ impl<M: CodegenModule> Compiler<M> {
if let (Some(thread_pool), Some(thread_lock)) = (&self.thread_pool, &self.thread_lock) {
let _lock = thread_lock.lock().unwrap();
let dim = thread_pool.current_num_threads();
let barrier = Arc::new(Barrier::new(dim));
unsafe {
(self.jit_functions.barrier_init.unwrap())();
}
Expand All @@ -241,7 +240,6 @@ impl<M: CodegenModule> Compiler<M> {
let dim = dim as u32;
// internal barriers in f use active spin-locks, so all threads
// must be available so the spin-locks can be released
barrier.wait();
f(idx, dim);
});
} else {
Expand Down

0 comments on commit b3b532f

Please sign in to comment.