Multi-threading

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....

May 3, 2023 · 1 min · 114 words · Me

reshape and permutedims

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....

May 2, 2023 · 1 min · 181 words · Me

SymPy.jl

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....

April 16, 2023 · 1 min · 200 words · Me