# General Usage

**URL:** https://discourse.julialang.org/c/usage/6.md?page=375

[Latest](https://discourse.julialang.org/latest.md) · [Categories](https://discourse.julialang.org/categories.md) · [Tags](https://discourse.julialang.org/tags.md)

**Page:** 376

---

## [Efficient way to multiply a matrix by each element of another matrix and store in one large matrix](https://discourse.julialang.org/t/efficient-way-to-multiply-a-matrix-by-each-element-of-another-matrix-and-store-in-one-large-matrix/89552)

<div class="topic-metadata">

**Author:** [@CeterisPartybus](https://discourse.julialang.org/u/CeterisPartybus)\
**Replies:** 3\
**Last updated:** [October 31, 2022, 1:30pm UTC](https://discourse.julialang.org/t/efficient-way-to-multiply-a-matrix-by-each-element-of-another-matrix-and-store-in-one-large-matrix/89552 "2022-10-31T13:30:49Z")

</div>

I need to multiply a matrix A with each element of another matrix B. The result should be stored in one large matrix, C. This should work for arbitrarily large matrices. To give a specific example: Take to matrices Aan…

---

## [How to use Markdown reference links with Documenter.jl](https://discourse.julialang.org/t/how-to-use-markdown-reference-links-with-documenter-jl/84232)

<div class="topic-metadata">

**Author:** [@samo](https://discourse.julialang.org/u/samo)\
**Replies:** 2\
**Last updated:** [October 31, 2022, 11:27am UTC](https://discourse.julialang.org/t/how-to-use-markdown-reference-links-with-documenter-jl/84232 "2022-10-31T11:27:03Z")

</div>

I usually use Markdown reference links quite often in Markdown files for documentation, e.g. to write: CellArrays relies on \[StaticArrays.jl\], \[Adapt.jl\] and the Julia GPU packages \[CUDA.jl\] and \[AMDGPU.jl\]. \[StaticArra…

---

## [Bootstrapping is fast on M1 Max, slow on HPC Knights Landing / Broadwell](https://discourse.julialang.org/t/bootstrapping-is-fast-on-m1-max-slow-on-hpc-knights-landing-broadwell/89463)

<div class="topic-metadata">

**Author:** [@JAF](https://discourse.julialang.org/u/JAF)\
**Replies:** 12\
**Last updated:** [October 31, 2022, 9:05am UTC](https://discourse.julialang.org/t/bootstrapping-is-fast-on-m1-max-slow-on-hpc-knights-landing-broadwell/89463 "2022-10-31T09:05:26Z")

</div>

Hi, I have successfully converted a statistical bootstrapping experiment originally written in Python. My workflow loads multiple datasets of grid data (Z sets of MxNxT) that represent numerical simulations with varying…

---

## [Why is this type check so slow](https://discourse.julialang.org/t/why-is-this-type-check-so-slow/89546)

<div class="topic-metadata">

**Author:** [@Lilith](https://discourse.julialang.org/u/Lilith)\
**Replies:** 1\
**Last updated:** [October 31, 2022, 8:32am UTC](https://discourse.julialang.org/t/why-is-this-type-check-so-slow/89546 "2022-10-31T08:32:11Z")

</div>

Shouldn’t type checks for statically known types be free at runtime? julia\> const IntUInt = Union{Int, UInt} Union{Int64, UInt64} julia\> struct T{U \<: Integer} x::U end julia\> @btime 1 isa T{\<:IntUIn…

---

## [ProfileView takes a long time for "using"](https://discourse.julialang.org/t/profileview-takes-a-long-time-for-using/89530)

<div class="topic-metadata">

**Author:** [@Palli](https://discourse.julialang.org/u/Palli)\
**Replies:** 2\
**Last updated:** [October 31, 2022, 7:35am UTC](https://discourse.julialang.org/t/profileview-takes-a-long-time-for-using/89530 "2022-10-31T07:35:53Z")

</div>

julia\> using Profile julia\> @profile using PythonCall \`\`profiletook a long time (way more than 10 sec.), vs@time using. Is that normal? I thought it, or when using @profilevewdirectly, had hung (maybe it did). It did f…

---

## [Is it possible to add template programming and Metaclasses using Julia macro system?](https://discourse.julialang.org/t/is-it-possible-to-add-template-programming-and-metaclasses-using-julia-macro-system/89535)

<div class="topic-metadata">

**Author:** [@phantomcraft](https://discourse.julialang.org/u/phantomcraft)\
**Replies:** 5\
**Last updated:** [October 31, 2022, 7:33am UTC](https://discourse.julialang.org/t/is-it-possible-to-add-template-programming-and-metaclasses-using-julia-macro-system/89535 "2022-10-31T07:33:13Z")

</div>

I’m comming from Python and I’m very interested on Julia due to its string macros feature. Is it possible to implement template metaprograming and Metaclasses (Python has) just creating macros?

---

## [Confusion On Cartesian And Linear Index](https://discourse.julialang.org/t/confusion-on-cartesian-and-linear-index/89479)

<div class="topic-metadata">

**Author:** [@uje](https://discourse.julialang.org/u/uje)\
**Replies:** 4\
**Last updated:** [October 31, 2022, 6:09am UTC](https://discourse.julialang.org/t/confusion-on-cartesian-and-linear-index/89479 "2022-10-31T06:09:02Z")

</div>

I know cartesian index is to be of this nature: x\[i, j\] and linear index is of x\[i\]. With that said, let me explain my confusion. I have a 3D array: julia\> A = \[1 2 3; 4 5 6;;; 7 8 9; 10 12 13\] 2×3×2 Array{Int64, 3}: \[…

---

## [Substitutions for powers with new symbolic variables](https://discourse.julialang.org/t/substitutions-for-powers-with-new-symbolic-variables/89540)

<div class="topic-metadata">

**Author:** [@xyli](https://discourse.julialang.org/u/xyli)\
**Replies:** 0\
**Last updated:** [October 31, 2022, 5:08am UTC](https://discourse.julialang.org/t/substitutions-for-powers-with-new-symbolic-variables/89540 "2022-10-31T05:08:12Z")

</div>

Does anyone know if there are other Julia functions that can substitute “x\*y” by “a”? I had a discussion with Symbolics developers about it, but it seems to be a deadlock now. Please kindly see the discussion here,

---

## [@match alternative catchall](https://discourse.julialang.org/t/match-alternative-catchall/89426)

<div class="topic-metadata">

**Author:** [@Lincoln\_Hannah](https://discourse.julialang.org/u/Lincoln_Hannah)\
**Replies:** 4\
**Last updated:** [October 31, 2022, 2:14am UTC](https://discourse.julialang.org/t/match-alternative-catchall/89426 "2022-10-31T02:14:13Z")

</div>

I’d like to use @match within @chain @rtransform, but both the MLStyle and Match versions use \_ as the catchall which causes an error as its used by @chain. Is there an alternative catchall in any @match package? @ch…

---

## [What is the performance penalty for using MVector and MMatrix vs SVector and SMatrix](https://discourse.julialang.org/t/what-is-the-performance-penalty-for-using-mvector-and-mmatrix-vs-svector-and-smatrix/89490)

<div class="topic-metadata">

**Author:** [@prittjam](https://discourse.julialang.org/u/prittjam)\
**Replies:** 2\
**Last updated:** [October 30, 2022, 10:24pm UTC](https://discourse.julialang.org/t/what-is-the-performance-penalty-for-using-mvector-and-mmatrix-vs-svector-and-smatrix/89490 "2022-10-30T22:24:53Z")

</div>

How do the two data types store data underneath? As a more general question, when is an SVector or SMatrix allocated on the stack? Are MVector and MMatrix ever constructed on the stack?

---

## [Differentiate Fortran90 code that implements a Boundary element method](https://discourse.julialang.org/t/differentiate-fortran90-code-that-implements-a-boundary-element-method/89524)

<div class="topic-metadata">

**Author:** [@KapilKhanal](https://discourse.julialang.org/u/KapilKhanal)\
**Replies:** 2\
**Last updated:** [October 30, 2022, 9:11pm UTC](https://discourse.julialang.org/t/differentiate-fortran90-code-that-implements-a-boundary-element-method/89524 "2022-10-30T21:11:32Z")

</div>

I have a fortran90 BEM code that I need to calculate the adjoints of. I am very new to this ecosystem but saw some advice on using Enzyme to do so. Has anyone done similar for the BEM code before? Any help/pointers is a…

---

## [Method of struct](https://discourse.julialang.org/t/method-of-struct/89458)

<div class="topic-metadata">

**Author:** [@duan](https://discourse.julialang.org/u/duan)\
**Replies:** 27\
**Last updated:** [October 30, 2022, 7:53pm UTC](https://discourse.julialang.org/t/method-of-struct/89458 "2022-10-30T19:53:06Z")

</div>

I’ve being using Julia for less than a year, and I appreciate how multi-dispatch makes codes efficient. Meanwhile, I also miss the methods that come with Python or C++ classes. I know that a method obj.func(...) in Pytho…

---

## [Plots borking on SentinelArrays produced by CSV.read](https://discourse.julialang.org/t/plots-borking-on-sentinelarrays-produced-by-csv-read/89505)

<div class="topic-metadata">

**Author:** [@dlakelan](https://discourse.julialang.org/u/dlakelan)\
**Replies:** 8\
**Last updated:** [October 30, 2022, 6:42pm UTC](https://discourse.julialang.org/t/plots-borking-on-sentinelarrays-produced-by-csv-read/89505 "2022-10-30T18:42:48Z")

</div>

using CSV, DataFrames, DataFramesMeta, Downloads, StatsPlots Downloads.download("https://data.cdc.gov/api/views/g653-rqe2/rows.csv?accessType=DOWNLOAD","NWSSSarsCov2WastewaterConc.csv") Downloads.download("https://dat…

---

## [How to ensure function is type-stable and allocation-free](https://discourse.julialang.org/t/how-to-ensure-function-is-type-stable-and-allocation-free/89509)

<div class="topic-metadata">

**Author:** [@Max\_A](https://discourse.julialang.org/u/Max_A)\
**Replies:** 2\
**Last updated:** [October 30, 2022, 5:58pm UTC](https://discourse.julialang.org/t/how-to-ensure-function-is-type-stable-and-allocation-free/89509 "2022-10-30T17:58:24Z")

</div>

I am writing a function and I’m trying to ensure that it is type-stable and allocation-free. I am using the @code\_warntype to ensure type-stability and @btime to determine memory allocation. Here is my code: # we assum…

---

## [DifferentialEquations hangs when partitioning state vector](https://discourse.julialang.org/t/differentialequations-hangs-when-partitioning-state-vector/89455)

<div class="topic-metadata">

**Author:** [@DorianC](https://discourse.julialang.org/u/DorianC)\
**Replies:** 3\
**Last updated:** [October 30, 2022, 1:29pm UTC](https://discourse.julialang.org/t/differentialequations-hangs-when-partitioning-state-vector/89455 "2022-10-30T13:29:43Z")

</div>

I have enjoyed using ArrayPartitions to segregate information such as differential vs algebraic states when running DifferentialEquations. It worked great for what I used: one partition. Now I am trying to segregate the…

---

## [Julia matrix-multiplication performance](https://discourse.julialang.org/t/julia-matrix-multiplication-performance/55175)

<div class="topic-metadata">

**Author:** [@evanfields](https://discourse.julialang.org/u/evanfields)\
**Replies:** 20\
**Last updated:** [October 30, 2022, 12:02pm UTC](https://discourse.julialang.org/t/julia-matrix-multiplication-performance/55175 "2022-10-30T12:02:57Z")

</div>

Julia’s built in matrix multiplication seems to be much faster than this LoopVectorization snippet? julia\> r1 = rand(1000, 1000); r2 = rand(1000, 1000); c = zeros(1000, 1000); julia\> @belapsed $c .= $r1 \* $r2 0.0257447 …

---

## [Muladd! (useful?)](https://discourse.julialang.org/t/muladd-useful/89517)

<div class="topic-metadata">

**Author:** [@photor](https://discourse.julialang.org/u/photor)\
**Replies:** 1\
**Last updated:** [October 30, 2022, 7:57am UTC](https://discourse.julialang.org/t/muladd-useful/89517 "2022-10-30T07:57:00Z")

</div>

Hi, I know there is the muladd function, but it seems there isn’t an in-place version muladd! of it?

---

## [Failed to precompile packages](https://discourse.julialang.org/t/failed-to-precompile-packages/89362)

<div class="topic-metadata">

**Author:** [@David\_F](https://discourse.julialang.org/u/David_F)\
**Replies:** 2\
**Last updated:** [October 30, 2022, 6:45am UTC](https://discourse.julialang.org/t/failed-to-precompile-packages/89362 "2022-10-30T06:45:43Z")

</div>

I’m trying to run the example code for solving the heat equation with MethodofLines.jl https://docs.sciml.ai/MethodOfLines/stable/tutorials/heat/ But when I run the julia, I get the following errors: 4 dependencies …

---

## [Using @eval in a function](https://discourse.julialang.org/t/using-eval-in-a-function/89488)

<div class="topic-metadata">

**Author:** [@vitaminace33](https://discourse.julialang.org/u/vitaminace33)\
**Replies:** 17\
**Last updated:** [October 29, 2022, 10:40pm UTC](https://discourse.julialang.org/t/using-eval-in-a-function/89488 "2022-10-29T22:40:23Z")

</div>

Hi! I am trying to extend the methods of a collection of functions programmatically with no partial success. foo(x::Real) = x for f in (:foo,) @eval ($f)(x::Complex) = x' end function fun() foo(x::Real) = x …

---

## [How to draw a phase portrait of a system of differential equations](https://discourse.julialang.org/t/how-to-draw-a-phase-portrait-of-a-system-of-differential-equations/89492)

<div class="topic-metadata">

**Author:** [@Freya\_the\_Goddess](https://discourse.julialang.org/u/Freya_the_Goddess)\
**Replies:** 5\
**Last updated:** [October 29, 2022, 6:50pm UTC](https://discourse.julialang.org/t/how-to-draw-a-phase-portrait-of-a-system-of-differential-equations/89492 "2022-10-29T18:50:22Z")

</div>

Hi all, I have this uncoupled linear system \\dot{x}\_{1} = -x\_{1} \\dot{x}\_{2} = 2x\_{2} the system can be written in matrix form as \\dot{x} = Ax with A = \[-1 \\ 0; 0 \\ 2\] the general solution are: x\_{1} (t) = c\_{1} …

---

## [How to Plot the Direction Field and Integral Curves Correctly with Plots](https://discourse.julialang.org/t/how-to-plot-the-direction-field-and-integral-curves-correctly-with-plots/89184)

<div class="topic-metadata">

**Author:** [@Freya\_the\_Goddess](https://discourse.julialang.org/u/Freya_the_Goddess)\
**Replies:** 8\
**Last updated:** [October 29, 2022, 6:30pm UTC](https://discourse.julialang.org/t/how-to-plot-the-direction-field-and-integral-curves-correctly-with-plots/89184 "2022-10-29T18:30:40Z")

</div>

Hi all, I have found a code in this discourse and modify it to solve the separable equation of: \\frac{dy}{dx} = \\frac{x^{2}}{1 - y^{2}} with separable equations, we obtain the equation for the integral curve is: -x^{…

---

## [@fastmath does not work in @tullio and exp](https://discourse.julialang.org/t/fastmath-does-not-work-in-tullio-and-exp/89448)

<div class="topic-metadata">

**Author:** [@zxm403089989](https://discourse.julialang.org/u/zxm403089989)\
**Replies:** 14\
**Last updated:** [October 29, 2022, 6:17pm UTC](https://discourse.julialang.org/t/fastmath-does-not-work-in-tullio-and-exp/89448 "2022-10-29T18:17:08Z")

</div>

As the title, when I want to make a list acted by exp, the system throw this mistake: start rt=rand(100); @inbounds @fastmath @tullio et\[n\] := exp(rt\[n\]) UndefVarError: exp\_fast not defined Stacktrace: \[1\] 𝒜𝒸𝓉! @…

---

## [How to Compute Analytical Derivative and Integral of trigonometric functions using Symbolic.jl and DiffRules.jl](https://discourse.julialang.org/t/how-to-compute-analytical-derivative-and-integral-of-trigonometric-functions-using-symbolic-jl-and-diffrules-jl/89480)

<div class="topic-metadata">

**Author:** [@Freya\_the\_Goddess](https://discourse.julialang.org/u/Freya_the_Goddess)\
**Replies:** 3\
**Last updated:** [October 29, 2022, 5:56pm UTC](https://discourse.julialang.org/t/how-to-compute-analytical-derivative-and-integral-of-trigonometric-functions-using-symbolic-jl-and-diffrules-jl/89480 "2022-10-29T17:56:55Z")

</div>

Hi all, I have this equation y = \\frac{1}{e^{\\frac{t}{2}}} \\left\[ \\int\_{t\_{0}}^{t} e^{\\frac{s}{2}} (10 + 5 \\ sin(2s)) \\ ds + c \\right\] \\\\ I want to ask how to solve this with Symbolics.jl and DiffRules.jl (even if t…

---

## [Coercing Data Type of Large Matrix](https://discourse.julialang.org/t/coercing-data-type-of-large-matrix/89494)

<div class="topic-metadata">

**Author:** [@nosewitz](https://discourse.julialang.org/u/nosewitz)\
**Replies:** 0\
**Last updated:** [October 29, 2022, 4:02pm UTC](https://discourse.julialang.org/t/coercing-data-type-of-large-matrix/89494 "2022-10-29T16:02:00Z")

</div>

I have a sparse matrix with dimensions 800 x 100,000 filled solely with binary data (1 or 0), when loading it into a table with MLJ, their type is determined to be count data. I am able to change it into the OrderedFacto…

---

## [Buffer to store data vectors](https://discourse.julialang.org/t/buffer-to-store-data-vectors/89377)

<div class="topic-metadata">

**Author:** [@andrey2185](https://discourse.julialang.org/u/andrey2185)\
**Replies:** 13\
**Last updated:** [October 29, 2022, 2:19pm UTC](https://discourse.julialang.org/t/buffer-to-store-data-vectors/89377 "2022-10-29T14:19:02Z")

</div>

Hello, I need a buffer to store data vectors. A pre-allocated vector as a buffer needs to be defragmented. A vector dictionary is 30-60 times slower than a vector due to memory allocation and needs a crutch to check th…

---

## [Splitting time periods in a DataFrame](https://discourse.julialang.org/t/splitting-time-periods-in-a-dataframe/89268)

<div class="topic-metadata">

**Author:** [@kobusherbst](https://discourse.julialang.org/u/kobusherbst)\
**Replies:** 10\
**Last updated:** [October 29, 2022, 10:10am UTC](https://discourse.julialang.org/t/splitting-time-periods-in-a-dataframe/89268 "2022-10-29T10:10:52Z")

</div>

I have a DataFrame with episodes of exposure of the form: PersonId::Int64 DateOfBirth::Date Sex::Int64 StartDate::Date EndDate::Date I would like to split each record on January 1, of each calendar year between :Start…

---

## [Skipping parts of a for loop in the first iteration](https://discourse.julialang.org/t/skipping-parts-of-a-for-loop-in-the-first-iteration/16252)

<div class="topic-metadata">

**Author:** [@mschauer](https://discourse.julialang.org/u/mschauer)\
**Replies:** 20\
**Last updated:** [October 29, 2022, 7:25am UTC](https://discourse.julialang.org/t/skipping-parts-of-a-for-loop-in-the-first-iteration/16252 "2022-10-29T07:25:51Z")

</div>

I crave a macro that does @for x in iter begin dosomethings() if $first\_iteration y = dothings\_differently(x) else y = dothings(y, x) end dootherthings() end branch free by rewritin…

---

## [Reading text files with wrapped numerical data](https://discourse.julialang.org/t/reading-text-files-with-wrapped-numerical-data/89409)

<div class="topic-metadata">

**Author:** [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Replies:** 8\
**Last updated:** [October 29, 2022, 6:46am UTC](https://discourse.julialang.org/t/reading-text-files-with-wrapped-numerical-data/89409 "2022-10-29T06:46:34Z")

</div>

In the following example, the input text file contains numeric data spread over several rows. Assuming that the number of columns (=7) is known and that all input data can be read as Float64, is there a better way to re…

---

## [Hide "Precompiling AbbreviatedStackTraces" message](https://discourse.julialang.org/t/hide-precompiling-abbreviatedstacktraces-message/89461)

<div class="topic-metadata">

**Author:** [@jar1](https://discourse.julialang.org/u/jar1)\
**Replies:** 1\
**Last updated:** [October 28, 2022, 7:41pm UTC](https://discourse.julialang.org/t/hide-precompiling-abbreviatedstacktraces-message/89461 "2022-10-28T19:41:40Z")

</div>

I have using AbbreviatedStackTraces in my startup.jl. Can I hide this message? julia\> using AbbreviatedStackTraces \[ Info: Precompiling AbbreviatedStackTraces \[ac637c84-cc71-43bf-9c33-c1b4316be3d4\] \[ Info: Skipping prec…

---

## [Fast square root of 3 x 3 matrix](https://discourse.julialang.org/t/fast-square-root-of-3-x-3-matrix/89378)

<div class="topic-metadata">

**Author:** [@AnshPatel7](https://discourse.julialang.org/u/AnshPatel7)\
**Replies:** 8\
**Last updated:** [October 28, 2022, 2:05pm UTC](https://discourse.julialang.org/t/fast-square-root-of-3-x-3-matrix/89378 "2022-10-28T14:05:04Z")

</div>

Hi, I’m currently using sqrt() from LinearAlgebra.jl to compute the square-root of 3 x 3 matrices repeatedly. But this has created a performance bottleneck. So I was wondering if there an implementation of a matrix squa…

[Previous page](https://discourse.julialang.org/c/usage/6.md?page=374)

[Next page](https://discourse.julialang.org/c/usage/6.md?page=376)
