S***y 发帖数: 186 | 1 SUBROUTINE SB(LMAX,Z,JL)
INTEGER::LMAX
COMPLEX::JL(0:LMAX),Z
INTEGER::L
COMPLEX(KIND=8)::DJL(0:LMAX),NORM
DJL(LMAX)=(0.0D0,0.0D0)
DJL(LMAX-1)=(1.0D0,0.0D0)
DO L=LMAX-2,0,-1
DJL(L)=(L+L+3)*DJL(L+1)/Z-DJL(L+2)
END DO
NORM=DJL(0)
DJL(0)=SIN(Z)/Z
NORM=DJL(0)/NORM
DO L=1,LMAX
DJL(L)=DJL(L)*NORM
END DO
JL=DJL
END SUBROUTINE SB
This subroutine tabulates Spherical Bessel Function in JL(0 |
|
a***e 发帖数: 413 | 2 第一次看到的时候没想到要push数组的位置,而不是push‘(’,结果怎么都做不出来。
后来看了讨论的idea是把Indices存起来,按照那个想法写了,却发现last的初值要设
成-1,而不是0。最后通过的答案,看着觉得好郁闷,想了好久。。。。。。。
int longestValidParentheses(string s) {
vector left;
int n=s.size();
int last=-1,lmax=0;
for (int i=0; i
{
if (s[i]=='(')
{
left.push_back(i);
}
else if (s[i]==')')
{
if (left.empty())
{
... 阅读全帖 |
|
l*******b 发帖数: 2586 | 3 没看明白人家的想法。。。自己另写了一个
int maxPIII(vector &p) {
/* observation:
* maxIII = maxI + max local drop OR maxI + another maxI
*/
int lmin = INT_MAX, lmax, ldrop, rise = 0, total = 0;
for(int i = 0; i < p.size(); ++i) {
if(p[i] < lmin) {
lmin = p[i];
lmax = p[i];
ldrop = rise;
/* reset ldrop as max of local drop and previous rise */
continue;
}
... 阅读全帖 |
|
l*******b 发帖数: 2586 | 4 没看明白人家的想法。。。自己另写了一个
int maxPIII(vector &p) {
/* observation:
* maxIII = maxI + max local drop OR maxI + another maxI
*/
int lmin = INT_MAX, lmax, ldrop, rise = 0, total = 0;
for(int i = 0; i < p.size(); ++i) {
if(p[i] < lmin) {
lmin = p[i];
lmax = p[i];
ldrop = rise;
/* reset ldrop as max of local drop and previous rise */
continue;
}
... 阅读全帖 |
|
i****h 发帖数: 321 | 5 大牛,我写了一个,可是指针有问题,能不能帮我看看啊?谢谢。
bool isBST(TreeNode *n, int *max, int *min){
if(n == NULL){
max = NULL;
min = NULL;
return true;
}
int *lmax, *lmin;
int *rmax, *rmin;
bool leftResult = isBST(n->left, lmax, lmin);
bool rightResult = isBST(n->right, rmax, rmin);
if( leftResult && rightResult ){
if(lmax != NULL && n->value < *lmax )
return false;
if(rmin != NULL && n->va |
|
s*****y 发帖数: 897 | 6 1.10 Given a two dimensional graph with 6000 points on it, find a line which
passes the most number of points.
Basic Idea: We need two points to define a line. So, for all possible lines,
check which has the max number of points passing though. Let’s say there
are N points, and P is the set of all points.
Algorithm:
Lmax = 0, Maxp=0 for all pairs of point (Pi,Pj) in P
calculate number of points m passing through the line L(P1,Pj) if (m > Maxp)
{
Maxp = m; Lmax = L(Pi,Pj);
} return Lmax;
Time com... 阅读全帖 |
|
d****n 发帖数: 233 | 7 This question can be asked in various forms, here is the one I was asked:
A carpenter is trying to build some furniture, he need a list wood blocks
with different length, say L1, L2, ... Ln where 1 <= Li <= LMAX for i = 1,2.
. n. He need to purchase whole wood blocks from the shop. The wood blocks
in the shop are fixed length, say LEN, LEN >= LMAX.
Can you help the carpenter save money by figuring out the minimum number of
whole wood blocks he need to purchase?
Any idea on how to solve this? |
|
s**9 发帖数: 207 | 8 invariable:
p1: start of substring,
p2: end of substring,
hashset: set of chars in substring.
pmax: start of answer so far
lmax: size of answer so far
forword p2, update hashset, pmax, lmax. depending on size of hashset,
forward p1 or p2. |
|
|
n********r 发帖数: 65 | 10 应该很简单,但是我忘了怎么证明了
一个 positive hermitian 矩阵 H,
Lmin = minimum eigenvalue of H
Lmax = maximum eigenvalue of H
H_ii = (i,i)-th entry of H
then
Lmin < H_ii < Lmax
怎么证明 |
|
J****r 发帖数: 274 | 11 来自主题: JobHunting版 - g 家面经 High throughput需要用到lock-free datastructure。Google一下LMAX Disruptor吧。 |
|
c*******y 发帖数: 1630 | 12 你说的是有后门的MT4平台。
找ECN的,像IB的IDEALPRO,DUKASCOPY和LMAX都比较透明的
起码IB不对赌,基本没stop hunting和刻意在数据时段lag data,
spread顶多增大一点点。不像很多MT4平台,非农时候spread从1.5pip
能增加到10-15pips
外汇确实相对来说是最难做的,但也有它的好处 |
|
|
|
|
|
H****S 发帖数: 1359 | 17 If you are really looking for high throughput concurrent programming
paradigm, I would try lmax disruptor instead.
For remote communication, akka does have a problem, that is unlike tcp, you
will not be guaranteed to never lose any message in the uncertain world of
network, not even if you register a death watch, so you have to add some
sequence id in the message, which sucks. |
|
|
h*******n 发帖数: 82 | 19 简单了解就学学mutex锁,同步之类老生常谈的东西,估计几天就搞定了。
进一步就上无锁,建议用C++11,推荐preshing.com, 明白什么是无锁编程,内核锁,
用户锁,自旋锁,操作系统调度,自旋策略,然后看看别人怎么写无锁的数据结构,尤
其掌握LMAX Disruptor,这个玩意号称是java的人搞的,但是我怎么觉得dpdk,linux
内核好多年前就有了。 |
|
p***o 发帖数: 1252 | 20 估计是HFT,github上有LMAX出的java轮子。 |
|
s***e 发帖数: 911 | 21 我的一个计算涉及很大维数的矩阵操作. 其中含有一个整数参数n, 维数是该参数的
平方, dim=n^2
在所有其他参数固定的情况下, n<=17, 整个计算可以顺利进行. n=18时, 出现
segment fault错误.
对矩阵赋值是通过调用一个子程序完成的:
call MAT0(dim,LMAX1,LMAX2,a,b,f,pil1,AT0)
这个调用没有问题. 返还的sparse矩阵AT0经查没有什么异常.
之后调用另外一个子程序,
call mat_product(NSITE-2,LMAX,dim,AT0,Z0L)
目的是要对AT0进行一系列操作. 现在发现调用过程出了segment fault错误,
根本没有进入这个子程序内部.
麻烦各位帮忙参考一下, 大概可能是什么样的问题所致.
机器系统是dual opteron 260, Fedora Core 2 64, gcc-g77-3.3.3.
THX |
|
R********s 发帖数: 182 | 22 我有fortran 的code YYY.f90 如下:
PROGRAM MAIN
!
implicit none
INTEGER lambda(2),lim
integer df(2),ifault
REAL q,nc(2),sigma,acc,trace(7),res
nc = (/0,0/)
lambda=(/0.5,0.5/)
df = (/1,1/)
q = 10
lim = 10000
sigma = 0
acc = 0.0001
res = 0
call compute(lambda,nc,df,2,sigma,q,lim,acc,trace,ifault,res)
END program MAIN
XXX.cpp的code 如下:
#define UseDouble 0 /* all floating point double */
#include
#include 阅读全帖 |
|