reshape on Boyoon's blog
https://boyoon-c.github.io/tags/reshape/
Recent content in reshape on Boyoon's blogBoyoon's bloghttps://boyoon-c.github.io/%3Clink%20or%20path%20of%20image%20for%20opengraph,%20twitter-cards%3E
https://boyoon-c.github.io/%3Clink%20or%20path%20of%20image%20for%20opengraph,%20twitter-cards%3E
Hugo -- gohugo.ioWed, 03 May 2023 00:00:00 +0000Multi-threading
https://boyoon-c.github.io/posts/28/
Wed, 03 May 2023 00:00:00 +0000https://boyoon-c.github.io/posts/28/How to check the number of threads Threads.nthreads() Output:
8 For me, I have eight threads at my disposal for code execution.
How to check thread id Threads.threadid() Output:
1 Since we are on the master thread, Threads.threadid() will return 1.
@threads Macro Below we create a with 10 elements in it, then use multi-threads to put thread id used to process the given for loop. To use multi-thread, we use Threads.reshape and permutedims
https://boyoon-c.github.io/posts/27/
Tue, 02 May 2023 00:00:00 +0000https://boyoon-c.github.io/posts/27/The elements in the reshaped matrix will always be orderded column-wise. For example, consider the following code:
using LinearAlgra C = [1,2,3,4,5,6] reshape(C, (2,3)) Output:
2×3 Matrix{Int64}: 1 3 5 2 4 6 Notice that number 2 is placed in the first column of the second row, instead of the second column of the first row.
Suppose that we want to create a 2-by-3 matrix where the first row is initially filled and the second row is filled afterwards.SymPy.jl
https://boyoon-c.github.io/posts/17/
Sun, 16 Apr 2023 00:00:00 +0000https://boyoon-c.github.io/posts/17/SymPy.jl When functions are linear in parameters, we can decompose a matrix of polynomials into a matrix of coefficients and a matrix of variables. To achieve this, we can use the SymPy package.
First we need to ensure that Julia recognizes variables and treats them as symbols.
using SymPy x, y = symbols("x, y") Then we can simply invoke thecoeff() method to extract coefficients from the polynomials.
p = x + 0.