由买买提看人间百态

topics

全部话题 - 话题: scalar
首页 上页 1 2 3 4 5 下页 末页 (共5页)
c**t
发帖数: 2744
1
来自主题: Programming版 - 简单的perl问题
下面这一段code在W2k3下运行一段时间就停止了(没有新的timestamp打印到stdout),
可能是怎么回事?
#!C:\perl\bin -w
use strict;
my ($t1, $t2, $dt);
my $DIR = 'C:\Scripts';
my $PHP = 'C:\PHP\php.exe';
my $SRC = 'getData.php';
my $INTERVAL = 3;
chdir($DIR);
my $i = 0;
while(1)
{
$t1 = time;
system($PHP, $SRC);
$t2 = time;
$dt = ($INTERVAL * 60) - ($t2 - $t1);
if($dt > 0)
{
print "[", scalar(localtime(time)), "] Sleeping $dt seconds\
n";
sleep( $dt );
m***b
发帖数: 11
2
想从一个array中随机抽样,比如,取两个.应当是常见问题.
#!/usr/local/bin/perl
#Define an Array and sampling size
my @myArray=('a','c','d','e','f','g','h','j','k','m','n','t');
my $numPick=2;
#use sub:selection_sample()
my @randPick=selection_sample(\@myArray,$numPick);
print (@randPick);
#### subroutine from perlmonk ####
sub selection_sample {
my ($array,$num)=@_;
die "Too few elements (".scalar(@$array).") to select $num from\n"
unless $num<@$array;
my @results;
my $pos=0;
while ( @results
t****t
发帖数: 6806
3
来自主题: Programming版 - how to initialize associate data in STL map
23.3.1.2 map element access [lib.map.access]
T& operator[](const key_type& x);
Returns:
(*((insert(make_pair(x, T()))).first)).second.
T(), is default-initialized:
8.5 Initializers [dcl.init]
7 An object whose initializer is an empty set of parentheses, i.e., (),
shall be default-initialized.
Default-initialization means:
5 To zero-initialize storage for an object of type T means:
--if T is a scalar type (_basic.
c**t
发帖数: 2744
4
来自主题: Programming版 - a vba question. please help
can I rephrase your requirment as "define a function to compute a named rang
e"?
Name should be the collection of cells or objects. I don't think you can def
ine the computed array (scalar) with a name.
t****t
发帖数: 6806
5
来自主题: Programming版 - a question of perl
how does it fail? this piece of code runs well on my system.
one thing you may want to know, if you put (the reference of) a filehandle
in an element of array, you may not use <...> to read a line from it. in
other word, or <$FH> works, but anything other than bareword or simple
scalar variable is interpreted as fileglob. if you have to use an array of (
the references of) filehandles, use readline(...) instead of <...>.

look
failed.
t****t
发帖数: 6806
6
来自主题: Programming版 - New "KENG" about Perl.
on the contrary, my point is, lvalue or not is not important at all, since
in C/C++, you can not change a scalar more than once between 2 sequence
points.
yes, it is a good habit to listen before speaking out and then regret it.

poster
then
O******e
发帖数: 734
7
来自主题: Programming版 - 一个fortran问题:
Each of the following is different from the other:
character(len=3)::sa ! rank=0 (scalar), size=na, shape=na, type=3-byte char
character(len=1),dimension(3)::sb ! rank=1, size=3, shape=(3), type=1-byte
char
character(len=3),dimension(1)::sc ! rank=1, size=1, shape=(1), type=3-byte
char
character(len=1),dimension(1,3)::sd ! rank=2, size=3, shape=(1,3), type=1-
byte char
character(len=1),dimension(3,1)::se ! rank=2, size=3, shape=(3,1), type=1-
byte char
(dennny's example is the first one, it
v*****r
发帖数: 1119
8
来自主题: Programming版 - help for Shell script commands
Perl version:
perl -anle 'print @F[2] if scalar @F>3' aa.txt
b*t
发帖数: 489
9
来自主题: Programming版 - 求教一个perl问题
自己写了一个简单的perl程序(自认水平是新手中的新手)。其中有一个步骤是检验每
个单词里面是不是含有一个特定的string,比如假如一个单词含有 "tion",我希望能
count++.
我现在写的是
if ($_ = ~/tion/) {
$count ++;
}
这样写的问题就是,如果一个单词含有两个 "tion",我只count了一次。
不知道有没有命令可以count一个scalar里面含有多少个字串(比如我说的 tion).
请多多赐教。
t*********e
发帖数: 1136
10
来自主题: Programming版 - 求教一个perl问题
s//g modifies $_. How about this:
my @m = ($_ ~= /tion//g);
$n += scalar(@m);
c*****e
发帖数: 3226
11
来自主题: Programming版 - 从今天开始起,学C++!
http://tinyurl.com/3dzltse
erlang vs scalar
t****t
发帖数: 6806
12
来自主题: Programming版 - PERL问题
yes, you can. but use @ to indicate slices, and use repetition operation to
repeat RHS (this is not like matlab, where scalars are automatically
expanded to match vector/matrix size)
@arr[(1..3, 4, 8)] = (5) x 5;
d*****u
发帖数: 17243
13
来自主题: Programming版 - 问个matlab的表达式
像A=(B==c)这种表达式
在matlab里是怎么运算的
其中c是scalar
A,B都是矩阵
w******p
发帖数: 166
14
来自主题: Programming版 - Perl:如何处理这种hash 结构,
$ cat file1 file 2 | perl -ne '@a=split; if(scalar @a==3){$h{$a[2]}{$a[1]}{$
a[0]}=[]; $h1{$a[0]}=[@a[2,1]]} else {if(exists $h1{$a[0]}){($p,$a)=@{$h1{$a
[0]}}; push @{$h{$p}{$a}{$a[0]}}, $a[1] }else{warn "no entry for found for $
_"}} END{use Data::Dumper; print Dumper(\%h)}'
$VAR1 = {
'P5' => {
'E' => {
'06' => [
'100',
'200',
... 阅读全帖
r*****3
发帖数: 143
15
来自主题: Programming版 - 《Clojure编程乐趣》英文文字版[PDF]
中文名: Clojure编程乐趣
原名: The Joy of Clojure
作者: Michael Fogus
Chris Houser
图书分类: 软件
资源格式: PDF
版本: 英文文字版
出版社: Manning
书号: 9781935182641
发行时间: 2011年
地区: 美国
语言: 英文
简介:
内容介绍:
If you've seen how dozens of lines of Java or Ruby can dissolve into just a
few lines of Clojure, you'll know why the authors of this book call it a "
joyful language." Clojure is a dialect of Lisp that runs on the JVM. It
combines the nice features of a scripting language with the powerful
features of a production environment—feat... 阅读全帖
n*w
发帖数: 3393
16
来自主题: Programming版 - C# is light-years ahead of Java now
Clr also had ironpython, iron ruby, scalar, closure, .... Etc
i*********n
发帖数: 58
17
Template function with scalar argument.
Compiler will optimize away the flag.
#include
using namespace std;
#define foo_plus foo
#define foo_minus foo
template
int foo(int a, int b) {
return plus ? (a + b) : (a - b);
}
int
main( int args, char *argv[] )
{
cout << foo_plus(5, 2) << endl;
cout << foo_minus(5, 2) << endl;
return 0;
}
f*****c
发帖数: 3257
18
来自主题: Programming版 - 包子求助matlab编程问题
一直不熟悉matlab语言,特别是循环问题,最近终于碰到大麻烦了,10个包子求助!
我用如下的代码,对38个国家的货币回报分别跟10个跨国公司的季度回报做资产组合,
但是写完这个代码,matlab居然停不下来了,请问各位大神,这是怎么回事?
----------------------------------
for y=1:38
%currency equity return
eval(['su',num2str(y),'=r',num2str(y),'-cost']); % net currency return
eval(['rr',num2str(y),'=zeros(q,s)']); % construct the whole currency return
matrix for (s+1) leverage
for i=1:s
for j=1:q
eval(['rr',num2str(y),'(j,i)=(su',num2str(y),'(j)-(fai(j,i)*leverage
(i)))/(1-leverage(i))']);
... 阅读全帖
f*****c
发帖数: 3257
19
来自主题: Programming版 - 包子求助matlab编程问题

是小弟无能,每次都要对38个国家做同样的操作~~下面是其中一个国家r1表示第一个
国家的货币回报。
s=100;% 100 types of currency
currency=zeros(s,1); %100*1
q=size(r1,1); % 100 quarters
a=6;%risk aversion
a=5;% this is value of V/NW
for i=1:s %1:100
currency(i)=0.8+0.002*(i-1);
end
%s_h=[1;zeros(s-1,1)];
s_h=zeros(s,1);% share of currency
for i=1:s
s_h(i)=a*(1-currency(i));% now assume NW/V=20%
end
cost=0.014.*ones(s,1);%assume annual rate of cost+tax=1.4%*4=5.6%;
%currency equity return
su=r1-cost; % net currency return
rr1=zeros(q,s... 阅读全帖
s*w
发帖数: 729
20
来自主题: Programming版 - 包子求助matlab编程问题
非大师,不过 matlab 断断续续用过10多年
matlab 里面不用动态生成变量,你想生成 r1,r2...r38 的话,应该直接用
r = cell(1,38)
然后 r{i} 里面放你的 ri
如果你的 r1,..r38 size 一样的话,连 cell 都不用,直接用 matrix
r = zeros(38,1) 如果 ri 是 scalar
r = zeros(38,3,3) 如果 ri 是 3*3 matrix
个人偏见,matlab 是最好学好写的语言; 可惜没啥大用,学得再好也找不到工作,所以
有机会的话,还是练练别的语言,找工也容易些
k**********g
发帖数: 989
21

Python is great for deploying code from server to worker nodes - just send
the source code, and run the interpreter. I'm glad to hear that Java and
Scalar can work that way too. This is unlike DLL deployment on Windows -
compile, digitally sign with certificate, run MSI installer, etc.
l**********n
发帖数: 8443
22
来自主题: Programming版 - scalar compiler error on annotation
if the annotation has a parameter which allows default value, such as the
following:
String serialized() default "";
String value()
then the compiler cannot recognize the serialized parameter.
I am using a Intellij 10. don't know how to change the compiler inside
intellij.
On Intellij 12, you can change the compiler to avoid this problem.
l**********n
发帖数: 8443
23
来自主题: Programming版 - scalar compiler error on annotation
I switch to use eclipse. Then it works. I guess all commercial IDEs suck
z****e
发帖数: 54598
24
来自主题: Programming版 - scalar compiler error on annotation
你都有钱搞idea了,为什么不干脆再卖一个高级一点的版本?
富就要富到底
l**********n
发帖数: 8443
25
来自主题: Programming版 - scalar compiler error on annotation
I have a higher version too, which works.
l**********n
发帖数: 8443
26
来自主题: Programming版 - scalar compiler error on annotation
I got it. have to recompile the whole maven project.
k**********g
发帖数: 989
27

Because of the lack of operator overloading, Java needs a different
implementation paradigm for image processing.
Before further explanation, let me point out that scalar code in MATLAB is
first compiled into an intermediate Java representation before being
executed. (This is what I heard in school, but not what I could verify. I'm
just quoting here.)
Firstly, a mathematical expression intended for image processing would be
parsed from a string into an "expression tree". The variable names woul... 阅读全帖
d****n
发帖数: 1637
28
来自主题: Programming版 - perl 匹配问题
I dont know well regex in perl; neither I want to.
Here is a non-regex solution
my @splits = split('-', $string);
if(scalar(@splits ) >2 && $splits[0] eq $splits[1]){
# do your stuff
}
e*******o
发帖数: 4654
29
来自主题: Programming版 - 如何动态定义类和方法
http://perldoc.perl.org/perlobj.html#Method-Call-Variations
Perl also lets you use a scalar containing a string as a class name:
e*******o
发帖数: 4654
30
来自主题: Programming版 - 如何动态定义类和方法
http://perldoc.perl.org/perlobj.html#Method-Call-Variations
Perl also lets you use a scalar containing a string as a class name:
j*****v
发帖数: 7717
31
来自主题: Programming版 - 王垠新文 为Java说句公道话
scalar的確是坨屎
不過把Ocaml port到.net,這也不能說微軟設計牛逼吧
s*****w
发帖数: 1527
32
来自主题: Programming版 - Perl 6 改动很大很恶心
Was: $#array+1 or scalar(@array)
Now: @array.elems
Index of last element in an array:
Was: $#array
Now: @array.end
Regex match is done with the smart match operator ~~, the perl 5 match
operator =~ is gone.
if "abc" ~~ m/a/ { ... }
Was: for ($i=0; $i<10; $i++) { ... }
Now: loop ($i=0; $i<10; $i++) { ... }
loop can also be used for infinite loops:
Was: while (1) { ... }
Now: loop { ... }
奶奶的最根本的数组都改了,这是在自杀啊

发帖数: 1
33
来自主题: Programming版 - Blackberry的QNX有谁用过么?
又是沒有做過server cpu的人在順嘴胡說,server cpu比embedded cpu複雜一個數量級
,根本原因就是內存虛擬化和IO虛擬化,非常非常多的花樣和專利技術,MCU那種實模
式,in-order scalar太簡單了。即使是PowerPC(我猜是你的老東家),對IO虛擬化也
支持很差。還有為什麼自動駕駛一定要硬件虛擬化,因為安全,不會跑飛。
g****t
发帖数: 31659
34
来自主题: Programming版 - Blackberry的QNX有谁用过么?
視覺是最靠譜的深度學習應用。別的方法不可行。
攝像頭這條鏈的朝向是出货巨大的AI/DL芯片。
說了你也聽不懂。
這塊可以產生出每年出貨幾十億的新型CPU的。


: 又是沒有做過server cpu的人在順嘴胡說,server cpu比embedded cpu複
雜一個
數量級

: ,根本原因就是內存虛擬化和IO虛擬化,非常非常多的花樣和專利技術,
MCU那
種實模

: 式,in-order scalar太簡單了。即使是PowerPC(我猜是你的老東家),
對IO虛
擬化也

: 支持很差。還有為什麼自動駕駛一定要硬件虛擬化,因為安全,不會跑飛。

j*c
发帖数: 97
35
来自主题: Unix版 - System Environment variables in Perl
good idea. but how to redirect the output of "uname" or "whoami" to
a scalar variable in perl?
b****s
发帖数: 472
36
来自主题: Unix版 - System Environment variables in Perl
it work, haha.
actually you can call any shell command and get the output
in a scalar variablie like this.
like $list = `ls -l`
e****e
发帖数: 179
37
【 以下文字转载自 Linux 讨论区 】
发信人: engine (boxing cat), 信区: Linux
标 题: help on replacing text in a file
发信站: BBS 未名空间站 (Wed Oct 31 11:42:35 2007)
I would like to replace string 1 with string 2 in file3.dat, here is what I
did:
#!/usr/bin/perl
@inputfile= ("string1");
@outputfile=("string2");
@attfile=("file3.dat");
$mytempfile=$inputfile[0];
$youtempfile=$outputfile[0];
$hisfile=$attfile[0];
perl -pi -e 's/$mytempfile/$youtempfile/' $hisfile;
The program reports an error:
Scalar found where operator ex
t*****g
发帖数: 1275
38
来自主题: Unix版 - how to count string times using perl
perl -e 'print scalar split /AB/, "ABCDDDEEDDABDDEAAB";'
a*********n
发帖数: 16
39
milliman是profit center based的。。每个profit center自负盈亏。。不同practice
算法可能不一样。。原来life是有一个formula。。按照个人billable hour target以
上的小时给。。一年target我记得是1200?。。公式里还有一个scalar factor是浮动
的。。一般按照profit center的盈利走。。具体我没怎么关心过。。但是以我个人经
验来说。。每年bonus都在base 80% - 100%左右。。不过这个bonus structure被改了
。。现在已经彻底discretionary 了。。今年还不知道结果如何~
a*********n
发帖数: 16
40
milliman是profit center based的。。每个profit center自负盈亏。。不同practice
算法可能不一样。。原来life是有一个formula。。按照个人billable hour target以
上的小时给。。一年target我记得是1200?。。公式里还有一个scalar factor是浮动
的。。一般按照profit center的盈利走。。具体我没怎么关心过。。但是以我个人经
验来说。。每年bonus都在base 80% - 100%左右。。不过这个bonus structure被改了
。。现在已经彻底discretionary 了。。今年还不知道结果如何~
f*******d
发帖数: 339
41
译的不太准确, scalar field 应译为标量场, dark energy 一般译为暗能量。
唉, 两年前我就知道这个塌缩的结果, 还和当时的老板讨论过,
不过没想到要深入研究下去写成文章, 因为当时觉得没太大意义,而且以前也有人写过文章。
现在想想亏了, 后来Steinhardt, Ovrut, Turok, Linde 这些大腕往string, Supergravity 上一扯,
硬是把这玩意炒火了。
h*********c
发帖数: 78
42
Your questions is so not clear, what is "scalar"? How does it related to
sequence motif?
In general, you definitely need to align RNA-seq reads to the genome, that's
the very first step for further analysis. You also need to consider
possible mutations when searching for motifs.
S*M
发帖数: 10832
43
我说的scalar(vs vector)就是对应每个transcript,都有一个实验测得的标量
现在想找到一个sequence motif来解释这个标量的变化
我们想干的好像类似预测transcription factor binding site的motif
不过后者里,sequence motif解释的因变量是discrete的

's
b*******r
发帖数: 62
44
Hi thanks a lot for your input. What you said about number of cells,
computation time and why millions cells needs are nothing new.
i am waitng for your input from aspect of physics and numerical error
analysis about PDE.
By the way, the reason why you upstream guys need so many cells is not
because of how large your field it. hint1. if you have homgoeneous scalar
perm, you will use much less number of cells (faster convergence rate). why?
hint2: numerical simulation around well is tougher, w
c****w
发帖数: 565
45
来自主题: CivilEngineering版 - Question on Tensor (转载)
【 以下文字转载自 Mathematics 讨论区 】
发信人: cswbww (啥也别想,赶紧做!一份耕耘,一份收获!), 信区: Mathematics
标 题: Question on Tensor
发信站: BBS 未名空间站 (Mon Apr 6 04:43:28 2009)
which one of following is true? A is scalar, a and b are 2nd order tensors.
g***i
发帖数: 90
46
来自主题: Computation版 - help on interface for Matlab and Fortran
//copied from matlab
A First Example -- Passing a ScalarLet's look at a simple example of Fortran
code and its MEX-file equivalent. Here is a Fortran computational routine t
hat takes a scalar and doubles it. subroutine timestwo(y, x)
real*8 x, y
C
y = 2.0 * x
return
end
Below is the same function written in the MEX-file format. C================
==============================================
=
C timestwo.f
C Multiply the input argument by 2.
C
C This is
s**i
发帖数: 381
47
来自主题: Computation版 - how to get a linearity of a 3D field?
Hi there,
I have a question.
Say I have computed a scalar field in a 3D space. I want to know how linear
this field is,i.e, how close it is too
f=a*x+b*y+c*z+d
I basically have a list of points with
x y z f
Is there any way statistics to show this?
Thanks a lot.
l*****y
发帖数: 32
48
来自主题: Computation版 - 用matlab算一个数值解
x = fzero(fun,x0) tries to find a zero of fun near x0, if x0 is a scalar.
在计算中,我怎么知道x0该怎么选取啊?
K*****n
发帖数: 23
49
fortran 90的话,用random_number( res ), res可以是
scalar,也可以是数组。
n********e
发帖数: 1789
50
来自主题: Computation版 - sigmaplot问题(zt)
谢谢
不过:
Warning: Z must not be a scalar or vector, not rendering surface.
不是很明白这个mesh图形是咋回事?是不是光3列没法画出来?
首页 上页 1 2 3 4 5 下页 末页 (共5页)