给定一组数字和一组二元运算,创建随机表达式树的最快方法是什么,或者在Mathematica中详尽检查每个可能的组合?
我想解决的是:
numbers={25,50,75,100,3,6} (* each can ONLY be used ONCE *)
operators={Plus,Subtract,Times,Divide} (* each can be used repeatedly *)
target=99
Run Code Online (Sandbox Code Playgroud)
找到要评估为目标的表达式树.
我有两个解决方案,我给出了表达式树包含4个数字和3个运算符的情况:
(定时在笔记本电脑上使用:Intel(R)Core(TM)2 Duo CPU T9300 @ 2.50GHz,3GB内存,尚未使用并行化,但在答案中非常受欢迎)
我的笔记本目前有点乱.因此,当我清理代码进行共享时,我首先想提出问题并希望获得原创想法和答案.
最大可能的情况是每个表达式树使用所有(6)数字和'Length [数字] -1'(5)运算符.
最大案例中方法的表现是:
我也在使用Mathematica 8.0.1,所以如果有任何方法可以在OpenCL中使用或使用编译函数与CompilationTarget - >"C"等,我不仅仅是所有的耳朵.
performance wolfram-mathematica tuples permutation expression-trees
我们目前在项目中遇到一些麻烦,因为我们发现在新的GHC版本中,像Char这样的旧模块默认是隐藏的,而新的模块(如Data.Char)是默认的.我现在正试图找出数据的版本., 控制.等模块被引入,哪个GHC版本首先隐藏像Char这样的包.
我正在尝试将程序从gfortran移植到ifort(英特尔Fortran编译器11).我坚持使用只能用gfortran编译的两个文件:
gfortran -x f77 -c daedrid.ff
gfortran -x f77-cpp-input -c daedris.ff
Run Code Online (Sandbox Code Playgroud)
当我尝试使用这些文件运行intel fortran编译器时,我得到:
ifort -fpp -c daedrid.ff
ifort: warning #10147: no action performed for specified file(s)
ifort -fpp -c daedris.ff
ifort: warning #10147: no action performed for specified file(s)
Run Code Online (Sandbox Code Playgroud)
并且没有创建任何目标文件.
现在,我该如何解决这个问题o_O?
编辑:将文件扩展名从ff重命名为fpp
cp daedrid.ff daedrid.fpp
cp daedrid.ff daedrid.fpp
Run Code Online (Sandbox Code Playgroud)
帮助:
ifort -fpp -c daedrid.fpp
daedrid.fpp(1483): (col. 9) remark: LOOP WAS VECTORIZED.
daedrid.fpp(1490): (col. 11) remark: LOOP WAS VECTORIZED.
daedrid.fpp(1499): (col. 13) remark: LOOP WAS VECTORIZED.
ifort -fpp -c daedris.fpp
daedris.fpp(1626): …Run Code Online (Sandbox Code Playgroud) 目前我使用:
transparent // ClearAll
transparent[i_] :=
Module[{r, g, b, a},
{r, g, b} = ImageData /@ ColorSeparate[i, "RGB"];
a = Unitize[3. - (r + g + b)];
(Image /@ {r, g, b, a})~ColorCombine~"RGB"
]
Run Code Online (Sandbox Code Playgroud)
注意:该功能仅使完美的白色RGB像素透明且有意.
第一个问题的更新:
使用Interleaving-> False可以消除ColorSeparate,ColorCombine
transparent0 // ClearAll
transparent0[i_] :=
Module[{r, g, b, a},
{r, g, b} = ImageData[i, Interleaving -> False];
a = Unitize[3. - (r + g + b)];
Image[{r, g, b, a}, Interleaving -> False, ColorSpace -> "RGB"]
]
Run Code Online (Sandbox Code Playgroud)
但表现更差:
transparent0[img]; //Timing …Run Code Online (Sandbox Code Playgroud) performance transparency wolfram-mathematica image-processing rgba
TCP 是否不负责通过在传输过程中发生丢失等可能需要的任何事情来确保通过网络完整发送流?
难道它没有做好吗?
为什么更高的应用层协议及其应用程序仍然执行校验和?
有没有人知道后缀" d + 0 "在下面的M1,M2和M4的作业中是什么意思,或者网上是否有任何资源或一本很可能找到这些信息的书?
subroutine plot( t, x, p, q, nga, nt, wron,
& ngq, gq, ngaq1, ngaq2, gaq, rwh, iwh )
implicit none
integer*4 nga, nt, ngq, ngaq1, ngaq2, iwh(*)
real*8 t, x(*), p(*), q(*), wron(nga,*),
& gq(ngq,*), gaq(ngaq1,ngaq2,*), rwh(*)
real*8 M1, M2, M3, M4, mr, mst, h3, Tc
integer*8 iflag
c DISCRETIZE1( Tc, rwh, iwh )
M1 = 0.1362d+0
M2 = 0.09806d+0
M3 = M1 + M2
M4 = 0.236d+0
mr = M1*x(1) + M2*x(2) + M3*x(3) …Run Code Online (Sandbox Code Playgroud) 鉴于F#记录:
type R = { X : string ; Y : string }
Run Code Online (Sandbox Code Playgroud)
和两个对象:
let a = { X = null ; Y = "##" }
let b = { X = "##" ; Y = null }
Run Code Online (Sandbox Code Playgroud)
和字符串的谓词:
let (!?) : string -> bool = String.IsNullOrWhiteSpace
Run Code Online (Sandbox Code Playgroud)
和功能:
let (-?>) : string -> string -> string = fun x y -> if !? x then y else x
Run Code Online (Sandbox Code Playgroud)
有没有办法使用F#语录来定义:
let (><) : R -> R -> R
Run Code Online (Sandbox Code Playgroud)
行为:
let c …Run Code Online (Sandbox Code Playgroud) 我在Hackage上看到的大多数软件包都是使用开源许可证发布的库,我认为我有一个带有缺少许可证字段的hackage上传的微弱内存,引发了hackage.haskell.org关于不使用开源许可证的抨击.
是否有规则说Hackage上托管的每个包都需要在开源许可下提供?
如果您声称存在此类规则,那么http://hackage.haskell.org/packages/archive/Cabal/1.14.0/doc/html/Distribution-License.html如何相关?
我从R的硬币包中得到了这个例子:
library(coin)
library(multcomp)
### Length of YOY Gizzard Shad from Kokosing Lake, Ohio,
### sampled in Summer 1984, Hollander & Wolfe (1999), Table 6.3, page 200
YOY <- data.frame(length = c(46, 28, 46, 37, 32, 41, 42, 45, 38, 44,
42, 60, 32, 42, 45, 58, 27, 51, 42, 52,
38, 33, 26, 25, 28, 28, 26, 27, 27, 27,
31, 30, 27, 29, 30, 25, 25, 24, 27, 30),
site = factor(c(rep("I", 10), rep("II", 10),
rep("III", 10), …Run Code Online (Sandbox Code Playgroud) 例如,我经常在手册页或其他文档中看到带数字后缀的命令或系统调用名称splice(2).虽然,一些出版物不包括这些数字,例如维基百科上的Splice.
我从来没有找到数字代表什么的解释,甚至不知道在哪里/如何开始搜索.
注意: 对于那些无法做出比无聊,无知的评论甚至是关闭有效问题的建议更好的人,请在此处查看接受的答案:使用GNU/Linux系统调用`splice`进行零拷贝Socket to Socket Haskell中的数据传输是如何为那些真正寻求建设性答案的人提供适当帮助的一个很好的例子!
嗨,我刚刚阅读PowerMod了Mathematica 8的文档,想要测试Haksell RSA包(ghc --make -O2 -O3 -fllvm -optlo-O3 test.hs):
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Control.Monad
import System.Random
import Codec.Crypto.RSA
import Data.ByteString.Lazy
import Data.ByteString.Char8
import Criterion.Main
import Criterion.Config
main :: IO ()
main = do
print m1
print m4
print m8
defaultMainWith defaultConfig (return ()) [
bgroup "RSA" [
bench "1" $ ed m1
, bench "4" $ ed m4
, bench "8" $ …Run Code Online (Sandbox Code Playgroud) haskell ×3
performance ×3
checksum ×1
compilation ×1
crc ×1
f# ×1
flags ×1
fortran ×1
freebsd ×1
gfortran ×1
ghc ×1
hackage ×1
intel ×1
licensing ×1
linux ×1
manpage ×1
notation ×1
open-source ×1
openssl ×1
package ×1
permutation ×1
posix ×1
quotations ×1
r ×1
records ×1
rgba ×1
rsa ×1
statistics ×1
system-calls ×1
tcp ×1
transparency ×1
tuples ×1