k******r 发帖数: 2300 | 1 For example, if we want to use bit operations to swap two variables without
using temporary variable. Any one can tell me how to develop an approach to
using bit operations to solve such problems step by step. Because the bit
operations usually don't look intuitive so the thread of thoughts behind that
is very important in mastering bit operations. Thanks so much for your
tutorial. |
|
s*********e 发帖数: 17 | 2 I give you a singly linked Linked List. Write a function to swap every second
node. [ie - 1->2->3->4->5->| becomes 2->1->4->3->5->|]
大家有没有更好的办法?
BOOL SwapList(node** pphead)
{
if(*pphead == NULL)
return FALSE;
// two pointers
node* pNode1 = *pphead;
node* pNode2 = (*pphead)->pNext;
*pphead = pNode2;
while(pNode2->pNext != NULL)
{
// two temporay pointers
node* pTmp1 = pNode1->pNext->pNext;
node* pTmp2 = pNode2->pNext->pNext;
|
|
c**a 发帖数: 316 | 3 可以用 swap 来交换 pointer 和 iterator 吗? |
|
I*******e 发帖数: 1879 | 4 ☆─────────────────────────────────────☆
ccca (cc) 于 (Sun Feb 15 21:40:43 2009) 提到:
swap(x,y);
不算
☆─────────────────────────────────────☆
SuperString (阳阳加油) 于 (Sun Feb 15 21:51:11 2009) 提到:
用 ^
☆─────────────────────────────────────☆
ccca (cc) 于 (Sun Feb 15 21:53:18 2009) 提到:
Yep. That is the answer, could u please elaborate.
I really dont know how to do it.
int x = rand();
int y = rand();
x = x^y; // does not work
☆─────────────────────────────────────☆
oHo (glasses) 于 (Sun |
|
|
a***y 发帖数: 2803 | 6 void swap(int *a, int *b) {
int c;
c=*a;
*a=*b;
*b=c;
} |
|
a***y 发帖数: 2803 | 7 void swap(int *a, int *b) {
int *c;
if (a && b) {
c=a;
*a=*b;
*b=*c;
}
} |
|
|
d****n 发帖数: 1637 | 9 my point is that making sense to swap two element actually same.
误. |
|
d*******u 发帖数: 186 | 10 In your code c is a pointer, and uninitialized.that's the problem.
void swap(int *a, int *b) {
int c;
c=*a;
*a=*b;
*b=c;
return;
} |
|
t****t 发帖数: 6806 | 11 好了不开玩笑.
第一, 写一个库函数, 首先要完成的是调用者的要求, 其次才是考虑节约成本. 你从头
到尾没完成调用的要求, 节约成本根本就是一句空话. 交换对象和交换对象的指针, 是
两件完全不同的事情. 库函数能做的, 是提供两个版本由调用者决定调用哪个.
第二, 回到本来的题目. 如果调用者要求交换指针, 应该是调用者自己把指针的指针传
进来, 就象你写的一样. 而不是库函数自己别出心裁, 限制只能交换指针或者"推荐"使
用指针的版本. 从根本上来说, 交换两个对象就是交换两个对象(指针也是对象之一).
除非知道对象内部的结构(即类本身有moving semantics或者specialize swap), 否则
创建一个新对象是不能避免的. |
|
t****t 发帖数: 6806 | 12 楼主问what's wrong with this swap function, 要求就是指出/改正错误. 你贴个
code回答又不作说明, 我缺省就认为你是在改正错误. 但是你的code做的是别的事情.
PS if you want to discuss, no pointing finger to person, alright? whether I
am guru or not is not relevant. |
|
c**********e 发帖数: 2007 | 13 Write a function to swap the two bytes of a 16-bit value.
What does it mean? |
|
|
m*********a 发帖数: 3299 | 15 我是没有看到用copy&swap的必要.早我这个简单复制没有必要 |
|
N******K 发帖数: 10202 | 16 std::move 有了 你还用swap这种远古社会的东西? |
|
m*********a 发帖数: 3299 | 17 move 是move other内存的内容,=是copy other 内存的内容
如果你move, 然后delete other, 那么this就指向other的已经释放的内存了
这不是=要的,我觉得
如果other中的variable都是atomic类型的话,shallow copy就行了,*this=other
如果other中有refence类型,就用std::swap进行deep copy |
|
s**i 发帖数: 30 | 18 【 以下文字转载自 Linux 讨论区 】
【 原文由 suyi 所发表 】
Is byte swap needed if I want to access data file generated
by other unix machine (SGI for example) on a pc running linux?
I know that Windows machine and Unix machine has different byte order
in saving data. Is this inherent property of hardware architechture or
operating system? |
|
L***z 发帖数: 454 | 19 I am very fucked in SWAP because the Schweser book is very confusing. On
Page 230 of Book 5, the book says we want to exchange 25m pounds for 50m
dollars. So I guess we will pay 25m pounds and get 50m dollars. The common
sense told me that we'll also receive the interest on the dollars (because
dollar is what we received) and pay the interest on the pounds (because
pound is what we paid). But the book then says exactly the opposite.
How am I wrong? |
|
L***z 发帖数: 454 | 20 Well, that makes swap easier to understand. Thanks a lot! |
|
L***z 发帖数: 454 | 21 Well, that makes swap easier to understand. Thanks a lot! |
|
m*****6 发帖数: 265 | 22 哪位大牛懂的请赐教,关于贷款方面的swap 的基本原理
非常感谢 |
|
d****g 发帖数: 325 | 23 在32位linux下,现在有4G内存,但是动不动就out of memory了,算了一下workspace
的数据大小,应该还不到3G。除去系统开销内存,怀疑matlab没用到swap空间。是不是
有什么参数没设置? |
|
c****p 发帖数: 6474 | 24 我前面有一帖说过,OS,硬件和MATLAB都支持64才行。
至于SWAP空间算不算连续的,这个取决于MATLAB对数据的操作。
我觉得最根本的还是解决你的数据集大小,比如说,分批处理,把处理完的数据写文件
之类的,总之不用的数据别让它呆在内存里面。3G的数据,都存在内存里面也不可能很
快处理完,不如几百M几百M地处理
吗? |
|
B*********h 发帖数: 800 | 25 ☆─────────────────────────────────────☆
dannyxz (DXZ) 于 (Wed Jun 6 00:12:21 2007) 提到:
One deal from my client is structured as equity index basket swap. One leg
is a capped and floored index basket return, the other leg is LIBOR. I
priced the equity leg as basket option with dividend taken into account. My
manager says it's not necessary.
那位高手提提意见,应该怎么样算?谢谢。
☆─────────────────────────────────────☆
scarface (人生犹如一场电影) 于 (Wed Jun 6 00:17:09 2007) 提到:
what is not neccessary? the dividen |
|
b*****g 发帖数: 20 | 26 如果一个funded swap, how do u handle cash part, on 1M libor or 3M libor |
|
r**u 发帖数: 69 | 27 what is funded swap? trs? |
|
s*********d 发帖数: 21 | 28 RWA for swap includes Notional RWA and MtM RWA, plus VaR RWA. The
determination of RWA depends on Risk Weight Factor for the counterparty, the
tenor of the contract and the availability of netting agreement. |
|
y****8 发帖数: 2 | 29 我要calibrate G2++,但是找不到historical cap/swap price。
Any help will be appreciated! |
|
s********k 发帖数: 5 | 30 不知为什么老板最近叫我做一个credit default swap的研究前景的presentation(阴
暗地认为他在上面
亏了钱)。
MD,我之前没怎么接触过。
xdjm们, 有没有什么好的idea. |
|
K*****Y 发帖数: 629 | 31 From what perspective? For modelng perspective, maybe:
-Liquidity and market completeness(e.g., bond-CDS basis, or basis between
asset swap-CDS basis, currency basis).
-Modeling of ABCDS (CDS on Asset Backed Securities) - calibaration of
parameters with the presence of prepayment risk, and CMCDS - Constant
Maturity CDS.
-CDS with embedded options. |
|
D*******a 发帖数: 3688 | 32 swap不能用annuity来replicate。
annuity的cash flow跟bond不同,因为每次payment里面包括principle和interest
越到后面,interest越小,对duration的贡献就越小。
duration
it.
really
or
coupon. |
|
t********t 发帖数: 1264 | 33 This is totally wrong. Only with the final principal paying back, the
duration of the floating arm can be almost zero. Because with the principal,
the floating arm can be treated as a money market account with current
value = principal.
And with the final principal added to the fixed arm, the duration of the
fixed side equal to the duration of the coupon bond.
发信人: sirlord (sirlord), 信区: Quant
标 题: Re: A question on swap duration - thanks for help!
发信站: BBS 未名空间站 (Wed Jun 3 20:42:26 2009)
NO!
Du |
|
w********r 发帖数: 290 | 34 请问是否可能开个个人账户交易Swap rate啊?本人最近研究一个strategy,outsample
backtesing annualized Sharpe ratio 高达2.6以上(没有考虑交易成本),所以想
自己开个户试试可不可行,还请知情者share 一些information,先谢过了 |
|
J*****n 发帖数: 4859 | 35
outsample
好像可以,只要你足够有钱。
不过有个问题好奇,你back-test的swap rate数据都是哪里来的? |
|
k***s 发帖数: 206 | 36 比如一个swap, party A pays 3M libor + spread and receives fixed.
这个refix到底指的是什么?吧floating leg的rate 改? 根据什么改?为什么要改?
不是contract一开始就定下的吗? |
|
r*******y 发帖数: 290 | 37 you pay the 3mo libor rate, which is reset every 3 month at future's libor
rate
you receive fix rate, which is fixed during the life of the swap |
|
|
d*j 发帖数: 13780 | 39 thanks for the input
of
of
can
off into some new company, no longer backed by the full faith and capacity
of the bank. so when they incur huge loss, the bank does not have to go down
with them.
swaps
. |
|
a***r 发帖数: 594 | 40 basically yes.
right now, a trading desk in say Goldman Sachs is backed by the full faith
of GS. as long as GS is not in bankruptcy, it has to honor the contract the
desk traded, in profit or in loss.
when spun off, the desk will not have any access to GS capital beyond the
extend of what GS spun off. so GS did not need to use any of its capital if
the spun off desk incurred trading loss.
There might be some negative consequencies:
1. segmentation of risk between underlying and swaps. a treasury |
|
t**o 发帖数: 64 | 41 Thanks a lot for the the education!
of
of
can
off into some new company, no longer backed by the full faith and capacity
of the bank. so when they incur huge loss, the bank does not have to go down
with them.
swaps
. |
|