我想从Julia (v0.7)中的邻接矩阵生成一个加权和有向网络。
到目前为止,我已经尝试过:
using LightGraphs
using SimpleWeightedGraphs
A = rand(100, 100)
G = Graph(A)
但我得到了错误:
ERROR: ArgumentError: Adjacency / distance matrices must be symmetric
Stacktrace:
[1] SimpleGraph{Int64}(::Array{Float64,2}) at /home/user/.julia/packages/LightGrap
我想反复从一个中取样,以便得到一个数字。
下面是实现我正在寻找的代码的一些代码:
const probabilities = [0.3, 0.3, 0.2, 0.15, 0.05]
const cummulative_probabilities = cumsum(probabilities)
function pickone(cummulative_probabilities)
n = length(cummulative_probabilities)
i = 1
r = rand()
while r >= cummulative_probabiliti
我在Julia中安装"Pkg“包时遇到了问题。以下是我使用Pkg.add(“Pkg”)后得到的错误:
unknown package Pkg
macro expansion at ./pkg/entry.jl:53 [inlined]
(::Base.Pkg.Entry.##1#3{String,Base.Pkg.Types.VersionSet})() at ./task.jl:335
Stacktrace:
[1] sync_end() at ./task.jl:287
[2] macro expansion at ./task.jl:303 [inlined]
[3] a
我试图从一个特定的方法中调用一个通用的方法,但不知道如何调用。 function fn(x)
# generic
...
end
function fn(x :: String)
# I want to call the generic version here
val = fn(x)
# do something with val and then return it
...
end 这个是可能的吗? 一种解决方法是使用帮助器函数,该函数既可以从泛型方法调用,也可以从特定方法调用。例如: function helper(x)
# main work is he
我有两个使用git跟踪的程序实例,所以我知道它们是同步的。一个实例在计算机A中,另一个实例在计算机B中。
机器A运行正常,但当我转到机器B时,我得到以下错误:
ERROR: InexactError()
in setindex! at array.jl:307
in setindex! at array.jl:345
in main at /path/to/main.jl:122
in include at ./boot.jl:246
in include_from_node1 at loading.jl:128
in process_options at ./client.jl:285
in
我的Julia版本是0.6.4。我正面临着安装Julia的问题。我安装了很长时间,但是julia突然停止了在REPL中的启动。因此,我删除了julia and Atom,并试图重新安装它。请给我一些建议。下面是我在REPL中启动Julia时的输出:
Hold on tight while we're installing some packages for you.
This should only take a few seconds...
ERROR:LoadError: unknown package Atom
macro expansion at .\pkg\entry.jl
我注意到,版本0.4.*的朱莉娅有一个--compile选项。
奇怪的是,我找不到任何关于它的文件。
我试图(在Ubuntu中)将一个julia脚本编译成一个可执行的LLVM字节码文件。但在此之前,我失败了
julia --compile=yes --output-bc test.bc test.jl
Segmentation fault (core dumped)
我还可以得到以下错误消息:
julia --compile=yes --output-bc test.bc test.jl
ERROR: could not open file boot.jl
如果我将一个boot.jl文件放在同
我尝试在Julia编程中使用三个不同的包(使用Atom IDE )。
我是朱莉娅的新人,请原谅我的无知!下面是我得到的信息:
Pkg.add("JuMP")
Pkg.add("DataFrames")
Pkg.add("GLPKMathProgInterface")
这些都运行成功。
然后我有:
using DataFrames
using GLPKMathProgInterface
using JuMP
"using DataFrames“行成功执行,但之后我得到一个预编译/安装错误:
ERROR: LoadError: GLPK no
我需要计算数据列的时间导数。
日期格式yyyy dd HH:MM:SS.sss
1-d NDSparse with 40508 values (6 field named tuples):
Date
2019-03-01T02:46:44.658
2019-03-01T02:46:44.811
2019-03-01T02:46:45.119
2019-03-01T02:46:45.222
2019-03-01T02:46:47.579
说:
help?> fill
search: fill fill! finally findall filter filter! filesize filemode FileSyntax FileSchema isfile CSVFile @__FILE__ CSVFileSyntax fieldtype fieldname
fill(x, dims)
Create an array filled with the value x. For example, fill(1.0, (5,5)) returns a 5×5 array of floats, with each e
在本地目录中有一个名为ModuleName.jl的文件。我相信这个文件包含一个有效的模块:
#!/usr/bin/env julia
module ModuleName
...
end
当尝试加载模块julia -e "using ModuleName"时,我得到:
ERROR: ArgumentError: ModuleName not found in path
in require at ./loading.jl:233
in process_options at ./client.jl:284
in _start at ./client.jl:411
所有这些都与本地目
今天早上,我安装了JuliaPro 1.4.1-1,并打开了一些初学者朱莉娅教程。
下面的代码在朱庇特笔记本中运行得很好,但是当我在Juno中运行它时会给出一个UndefVarError,无论我是在REPL还是作为.jl文件运行它。
n = 0
while n < 4
n += 1
println(n)
end
当我作为.jl运行它时,错误消息如下:
Error evaluating firsttest.jl
LoadError: UndefVarError: n not defined
in expression starting at C:\Users\Lipkin
在许多编程语言中,父类可以要求任何子类包含特定的字段。
如果场是静态的,同样的效果可以通过以下方式在Julia中实现。
julia> abstract Fruit
julia> type Apple <: Fruit end
julia> type Orange <: Fruit end
julia> type Banana <: Fruit end
julia> color(::Apple) = :red
color (generic function with 1 method)
julia> color(::Orange)
在运行Pkg.update()之后,我遇到了以下关于IJulia安装的错误消息:
WARNING: Module BinDeps uuid did not match cache file
===============================[ ERROR: IJulia ]================================
LoadError: __precompile__(true) but require failed to create a precompiled cache file
while loading /home/om/.julia/v0.4/IJ
我在Windows 8.1下运行Julia 1.0.2。
下面的内容让我相信Julia以"little-endian“的方式对待我的机器:
julia> VERSION
v"1.0.2"
julia> ENDIAN_BOM
0x04030201
help?> ENDIAN_BOM
search: ENDIAN_BOM
ENDIAN_BOM
The 32-bit byte-order-mark indicates the native byte order of the host machine. Little-endian
mach
我正在尝试定义两个结构,Node和Edge。节点包含一组边,而边包含目标节点和到达该节点的概率。由于问题的其余部分是如何构造的,所以我无法避免使用Edge对象。 struct Node
edges::Vector{Edge}
end
struct Edge
next::Node
probability::Float64
end 每当我尝试运行整个脚本时,我都会得到"UndefVarError:Edge is not defined“。 如果我尝试只运行边缘部分,我会得到"UndefVarError:Node is not defined“。 有没有办法(像C
在windows 10中,我使用了新版本的 JuliaPro JuliaPro v0.6.2.2中的原子。
ERROR: LoadError: MethodError: no method matching
setcharheight(::Float64)The applicable method may be too new: running in
world age 21685, while current world is 21686.
我没有得到错误的行号来帮助我像以前的版本那样采取行动。那么我怎样才能得到错误的位置呢?
在Julia中,我定义了一个类型,我需要编写一些与该类型的字段一起工作的函数。有些函数包含复杂的公式,在整个地方使用字段访问点表示法会变得很麻烦。因此,我最后将字段值放入局部变量中,以提高可读性。它工作得很好,但是有什么聪明的方法可以避免输入所有的a=foo.a行,或者让朱莉娅解析a作为foo.a等等呢?
struct Foo
a::Real
b::Real
c::Real
end
# this gets hard to read
function bar(foo::Foo)
foo.a + foo.b + foo.c + foo.a*foo.b - foo.