由买买提看人间百态

topics

全部话题 - 话题: function
首页 上页 1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)
c**********e
发帖数: 2007
1
【 以下文字转载自 JobHunting 讨论区 】
发信人: careerchange (Stupid), 信区: JobHunting
标 题: C++ Q98: Call member function in virtual function
发信站: BBS 未名空间站 (Fri Oct 21 20:04:02 2011, 美东)
What is the output of the following code? Why?
#include
using namespace std;
class base {
public:
void pay() { cout << "Base::pay" << endl; }
virtual void eat() { pay(); }
};
class derived: public base {
public:
void pay() { cout << "Derived::pay" << endl; }
};
void main() {
base* p = new derived;
... 阅读全帖
C***y
发帖数: 2546
2
来自主题: Programming版 - C++ function template问题
我有两个function,一个传入pointer,另外一个传入refernce
例如:
void func(int& a);
void func(double* a);
有办法为这两个function写一个function template吗?
Thanks!
c**********e
发帖数: 2007
3
来自主题: Programming版 - Can we define pure virtual function? (转载)
【 以下文字转载自 JobHunting 讨论区 】
发信人: careerchange (Stupid), 信区: JobHunting
标 题: Can we define pure virtual function?
发信站: BBS 未名空间站 (Wed Mar 28 22:22:19 2012, 美东)
class A {
public:
virtual int foo()=0;
};
A::foo() { return 0; }
That is can we have a function as pure virtual function
and also have defination like above?
Justify your answer. If yes, then tell me one situation
where we use that. If not tell me why not.
p***o
发帖数: 1252
4
来自主题: Programming版 - 请教一个C++中function pointer的问题。
You can have a non-template register_dec_handle function
(taking two paramters tag_id and ObjectGenerator) that
access generator_map directly and the template register_dec_handle
function should call that non-template one. Otherwise,
when the compiler instantiates the function template,
they need to see everything in the current translation
unit, which is obviously not possible here since generator_map
is static.
In short, if you know what is singleton, generator_map
should be one.

调用
对象
律;
如下
d*******i
发帖数: 77
5
来自主题: Programming版 - functional programming?
* Not having preference of functional programming vs object oriented
functional programming
* Not Talking which language is better than the other. They have different
ways/benefits/tradeoff to resolve the issues.
* Just want the topic of functional programming to be technical oriented.
* Industrial wide popularity does not mean any success of the language.
Actually it is a sadness of the language. I like Java, but when I worked
with a global fortune 100 client who has 3000 offshore cheap "develo... 阅读全帖
b***e
发帖数: 1419
6
来自主题: Programming版 - functional programming?
事实上scala和javascript都属于FP,只不过不像Haskell那么纯粹。FP的本质在于对
first class function和higher order function的支持。
我对四大牛人什么的说实话不感兴趣。我十年前也并非鼓吹FP。当年你挑起一个帖子,
说你认为functional language programmer都是"freaks who cannot think straight"
(大体是你的原话吧)。我路见不平而已。其中是非曲直有目共睹。
我职业潜水员,一向不太发帖子,这次多说几句主要是你们这些Java轮bash FP过激了
。我一向鼓励对FP的兴趣和探究,不愿看到这些志向过早的为世俗所羁。或有矫枉过正
。言止此尔。

status
d*******i
发帖数: 77
7
来自主题: Programming版 - functional programming?
* Not having preference of functional programming vs object oriented
functional programming
* Not Talking which language is better than the other. They have different
ways/benefits/tradeoff to resolve the issues.
* Just want the topic of functional programming to be technical oriented.
* Industrial wide popularity does not mean any success of the language.
Actually it is a sadness of the language. I like Java, but when I worked
with a global fortune 100 client who has 3000 offshore cheap "develo... 阅读全帖
b***e
发帖数: 1419
8
来自主题: Programming版 - functional programming?
事实上scala和javascript都属于FP,只不过不像Haskell那么纯粹。FP的本质在于对
first class function和higher order function的支持。
我对四大牛人什么的说实话不感兴趣。我十年前也并非鼓吹FP。当年你挑起一个帖子,
说你认为functional language programmer都是"freaks who cannot think straight"
(大体是你的原话吧)。我路见不平而已。其中是非曲直有目共睹。
我职业潜水员,一向不太发帖子,这次多说几句主要是你们这些Java轮bash FP过激了
。我一向鼓励对FP的兴趣和探究,不愿看到这些志向过早的为世俗所羁。或有矫枉过正
。言止此尔。

status
b*******s
发帖数: 5216
9
来自主题: Programming版 - C++ pointer to function is buggy
4.3 Function-to-pointer conversion [conv.func]
1 An lvalue of function type T can be converted to a prvalue of type “
pointer to T.” The result is a pointer tothe function.57
I think it is what happend.
b*******s
发帖数: 5216
10
来自主题: Programming版 - C++ pointer to function is buggy
4.3 Function-to-pointer conversion [conv.func]
1 An lvalue of function type T can be converted to a prvalue of type “
pointer to T.” The result is a pointer tothe function.57
I think it is what happend.
S*A
发帖数: 7142
11
来自主题: Programming版 - C++ pointer to function is buggy
C++ 我不熟悉啊,C 我还略知道一点。
这个相关的规定在 C99 6.6.9 Constant Expression 章节里面。
也就是说,地址表达式可以 “&” 取地址是显式取地址,
然后也可以对数组和函数隐含取地址,不需要 “&”。
数组和函数的地址是特例,取地址可以隐含,因为数组和函数的
本来使用都用特殊语法后缀,数组要后面有 【】,函数后面有()。
所以没有后缀的用法就可以分别定义。这里退化为地址是最自然的。
注意看原文里的 “implicitly" use an expression of array or function type.
9.
An address constant is a null pointer, a pointer to an lvalue designating an
object of static
storage duration, or a pointer to a function designator; it shall be created
explicitly using
the unary & operator or an inte... 阅读全帖
d****l
发帖数: 51
12
来自主题: Programming版 - 请教一个关于std::function的问题
根据编译的错误信息,processVector()的第二个变量被定义为std::function >,而在调用时传入的是std::_Bind_helper const std::_Placeholder<1>&>::type),编译器无法确定这二者是同一类型,因此报
错。你可以定义一个std::function变量然后把bind赋值给它(implicit
cast)之后在调用processVector时传入这个变量,或者直接static_cast (the
following code uses static_cast and works fine on my machine with gcc-4.8.0):
...
void testint()
{
...
processVector(arr, static_cast>(std::bind(&Foo::
print, this, _1)));
}
...
另外,二楼建议的写... 阅读全帖
s*i
发帖数: 5025
13
...
var spy = function(target){
var swap = target;
var count = 0;
return function(){
swap.apply(null, arguments);
count++;
console.log(count);
};
};
game.shoot = spy(game.shoot);
...
如果是在浏览器端运行的话,可以考虑各种 watch functions
h*i
发帖数: 3446
14
个人觉得,原因是这样:普通编程还是基于mutate state in place来工作的。说来说
去这比较底层,是由目前我们用的机器的体系机构决定的,而不是由人的思维和我们要
解决的问题的本质来决定的。当你需要解决的问题比较复杂,就需要更复杂的
primitive,就这么简单。传统语言一切问题都用三个primitive来解决:赋值,条件,
循环,当然什么都能干,但效率就有局限,所以需要更高层的抽象概念。所以我们有了
OOP。
但OOP的问题,在于其提供的高层抽像概念,对象,对象继承等等,其实不够普适。它
们真正适合的范围其实有限,但人们削足适履,非要一切都OOP,结果就搞出各种复杂
的design pattern,framework, architecture之类的,带来很多不是问题本身蕴含的
的复杂性。传统OOP抽象的一个重要的缺陷,就是action不是第一性的,这就是所谓的
“kingdom of nouns"的问题。所谓OOP design pattern,其实大多是对这个问题的
workaround。所以现在Java也要加lambda啥的,也要functional。为什么,因为... 阅读全帖
d******c
发帖数: 2407
15
语言只是工具,选好用的,自己喜欢的就是了。
语言对人影响很大,反过来人的思维不进步的话,还是可能以旧方式用新语言
最近读 functional thinking这本书,还不错,例子举得很好。
http://nealford.com/books/functionalthinking.html
用R用久了之后有了体会,再看functional就比较清楚了。回到python就发现过于过程
化。
区别在哪里?
R的性能一般,你有动力尽量用vectorized的现成函数,而不是写loop。实际上现成函
数能解决很多问题。这就强迫你把问题分解了。
vectorized,意味着每个函数都是pipeline的一环,每个处理一遍。相比一个巨型for
loop里面多个环节在一起,可能性能上有一点点优势,就是只遍历一遍,但是太多东西
纠缠在一起。从修改,测试角度多个独立函数要容易的多。函数要独立,就需要尽量没
有副作用,没有全局变量,这样逻辑上是简单的,想起来也轻松。
OO是封装,把方法封装在自己内部,太多内部变量,这适合不同的人,不同的部门相互
合作。functional里函数是一级成员,独立存在,重用函... 阅读全帖
m*****n
发帖数: 3575
16
list comprehension可以解决绝大部分你认为需要functional programming的运用
另外functional programming不是什么新鲜高级的概念,excel公式就是functional
programming
现代程序需要一阴一阳两大要素,数据和算法函数
函数式编程想抛弃数据,尤其是中间数据,本来就是痴心妄想
d******c
发帖数: 2407
17
John Carmark QuakeCon keynote talk about functional programming
https://www.youtube.com/watch?v=1PhArSujR_A
article: In-depth: Functional programming in C++
http://www.gamasutra.com/view/news/169296/Indepth_Functional_programming_in_C.php
用C++一样可以发挥functional programming的作用。关键是人的思维方法。
d******c
发帖数: 2407
18
他的文章写的很清楚了
A large fraction of the flaws in software development are due to programmers
not fully understanding all the possible states their code may execute in.
In a multithreaded environment, the lack of understanding and the resulting
problems are greatly amplified, almost to the point of panic if you are
paying attention. Programming in a functional style makes the state
presented to your code explicit, which makes it much easier to reason about,
and, in a completely pure system, makes thre... 阅读全帖
s*****w
发帖数: 1527
19
https://medium.com/javascript-scene/you-might-not-need-typescript-or-static-
types-aa7cb670a77b
TypeScript won't reduce the number of bugs.
TypeScript does suffer from added complexity for generics. Take a look at
this generic identity function in standard JavaScript:
const identity = arg => arg;
Compare that to the much noisier statically typed function in TypeScript:
function identity(arg: T): T {
return arg;
}

发帖数: 1
w**g
发帖数: 8
21
有如下两列数据:
3 2
2 4
9 6
1 8
6 10
第一列为原始数据, 第二为bin。Excel Analysis tools中Histogram可以用来计算第
一列数据的频率(以第二列为bin). 但是Histogram 不能自动执行。
我的问题是:怎样在第三列用Excel function计算出相应bin的频率。我用如下
function但其结果与Histogram所得结果不一样
A3=(countif($A$1:$A$5,"<"&B2)-countif($A$1:$A$5,"<="&B1))/count($A$1:$A$5)。
不知错在那?或有更好的function? Thanks much!
m**********2
发帖数: 57
22
来自主题: Biology版 - 有什么JAK/STAT3 functional assay么?
我的意思是Active JAK/STAT pathway出现某种phenotype,
而这种phenotype出现表明是激活JAK/STAT pathway 导致的。
Active JAK/STAT能够导致某种function assay or phenotype.
我现在是想加入某种drug出现某种function assay or phenotype.
说明drug是active JAK/STAT,
当然WB观察phosphorylation stat也是一种方法,但是只是从protein level。
我现在是想从功能level观察。想问问是不是有实践证明的Active JAK/STAT 导致的某
种function。
比如说某种细胞的分化,这样我加入drug,细胞出现分化,说明可能是active JAK/
STAT。 然后我再测量phosphorylation stat level increase,这样就比较完整了
l**********t
发帖数: 5754
23
【 以下文字转载自 Economics 讨论区 】
发信人: littletshirt (小仙鹤), 信区: Economics
标 题: help: calibrating utility function & risk aversion index for utility function
发信站: BBS 未名空间站 (Thu Mar 4 02:30:09 2010, 美东)
when using expected utility to select optimal portfolio choice, how do I
determine the function form & risk aversion / temporal discount to fit the
representative investor? reference articles are highly appreciated.
many thanks.
x*y
发帖数: 364
24
来自主题: Computation版 - help! bilinear basis function convergenc
Help for reference of the following info.
Bilinear basis function (for 4-node quadrilateral element) yields higher
convergence rate than strict linear basis function (for 3-node triangular
element).
I can't find any book provides the info of the convergence rate for comparing
the linear and bilinear basis function. Could anybody by any chance know this?
Thanks!
i***w
发帖数: 9
25
来自主题: Computation版 - MATLAB function call too slow (转载)
【 以下文字转载自 Programming 讨论区 】
发信人: Imnew (newbie), 信区: Programming
标 题: MATLAB function call too slow
发信站: BBS 未名空间站 (Fri Dec 29 14:03:11 2006)
After I profiled my programe, I found that the most time consuming part (
self time) in a function f(...) is something like this:
[A,B,C]= g(x,A,B,C);
I'm wondering why this statement will be slow? Since it's self time of f(...
),
it's not the time within function g(...). Does this mean the time is
consumed in copying matrix parameters A,B,C ? How can I i
l*****0
发帖数: 299
26
simultaneous和nonsimultaneous confidence bounds for function的区别?
在regression(curve fitting)中,simultaneous和nonsimultaneous confidence
bounds for function的区别是什么?请注意是confidence bounds for function不是
confidence bounds for future observations. matlab里有简短的解释,但很不清楚。
谢谢!
s*****w
发帖数: 2065
27
专门的paper我不知道,不过scott schaefer和paul oyer 2005的两篇讲ESO的
reservati
on function的paper里面好像就用过类似的calibration,你可以搜搜看。
good luck!

functions
on
CRRA
m****a
发帖数: 132
28
【 以下文字转载自 EE 讨论区 】
发信人: muitta (muitta), 信区: EE
标 题: naive question on orthogonal functions
发信站: BBS 未名空间站 (Tue Mar 21 13:57:03 2006)
Two 2-D function, P1(x,y) and P2(x,y), what does "these functions are
orthogonal to each other mean"? and how to calculate , or
what is the definition of the operation?
c******m
发帖数: 599
29
来自主题: Mathematics版 - 请问,什么是functional analysis?
Functional analysis is a branch of mathematics concerned with infinite-dimensional
vector spaces (mainly function spaces) and mappings between them. The spaces
may be of different, and possibly infinite, dimensions. These mappings are
called operators or, if the range is on the real line or in the complex
plane, functionals.
m****a
发帖数: 132
30
【 以下文字转载自 EE 讨论区 】
发信人: muitta (muitta), 信区: EE
标 题: naive question on orthogonal functions
发信站: BBS 未名空间站 (Tue Mar 21 13:57:03 2006)
Two 2-D function, P1(x,y) and P2(x,y), what does "these functions are
orthogonal to each other mean"? and how to calculate , or
what is the definition of the operation?
c****n
发帖数: 86
31
来自主题: Mathematics版 - Appell Hypergeometric Function
I'm doing numerical evaluation of second kind Appell Hypergeometric
Function with two variables.
Reference link:
http://mathworld.wolfram.com/AppellHypergeometricFunction.html
First kind Appell Hypergeometric Function with two variables is
implemented as AppellF1 in Mathemetica.
Is there any implementation of second kind Appell Hypergeometric
Function with two variables in any math software package? The brute
force implementation in Matlab often overflows.
Thanks for your input!
b****t
发帖数: 29
32
function [ x ] = temp( y )
if y <= 0
x = 1
else
x = -1
end
现在想对这个函数积分,我用quad(@(x) (temp(x)), -1, 1) 他就报错,因为这个函数
不是vector的形式。如果改成下面
function [ x ] = temp( y )
x = (y > 0) - (y < 0);
就可以用quad(@(x) (temp(x)), -1, 1)
但是如果我if复杂一点,我改怎么办呢?
b*****n
发帖数: 78
33
来自主题: Mathematics版 - Bessel function 一问
我考虑过的。有正交性的是 J(x_{mn}\rho)这样的Bessel function, 这里x_{mn}是m阶
Bessel function的第n个根。对于J_0(|\bar{r}-\bar{r_1}|)这样的Bessel function
,正交性不使用。 有没有其他办法?
b****t
发帖数: 114
34
来自主题: Mathematics版 - about quadratic functions...
Hi all,
for any quadratic plolynomial function, can I say there is a unique local
optimum if we define the local neighborhood as a unit ball ||x-y||<=1?
or simply consider the function defines on Z^n integer vectors.
Assume this function has a global optimum not at infinite.
Thanks a lot.
Beet
f*********g
发帖数: 632
35
The Siegel theta function is implemented in Mathematica as SiegelTheta[Omega
, s].
This function was investigated by many of the luminaries of nineteenth
century mathematics, Riemann, Weierstrass, Frobenius, Poincaré. Umemura has
expressed the roots of an arbitrary polynomial in terms of Siegel theta
functions (Mumford 1984).
http://mathworld.wolfram.com/SiegelThetaFunction.html

the
p******c
发帖数: 40
36
Suppose we have an unknown 2D function f(x,y). We define the projection of
this 2D function on any straight line:
g(u)=\int f(x,y) dv where u,v are perpendicular to each other.
If we know as many projections as possible, is it possible to regenerate the
unknown function f(x,y)?
Thanks a lot.
a***m
发帖数: 74
37
来自主题: Quant版 - stable density function calculation
Hello,
I am wondering if anyone have experience with Nolan1997 paper" Numerical
calculation of stable densities and distribution functions" formula to
calculate stable density functions?
I have some problems with the results for non-zero beta (skewness parameter)
. For zero beta, my limiting cases agree with Normal and Cauchy density
functions, though when x is around +-6, there are some jumps in the results.
For non-zero beta, my results don't make sense when x is around zero.
Any experience or
D*********Y
发帖数: 3382
38
math.h 没有cdf function。弄了个function自己numerically来算cdf,算的挺慢的如
果要求精确。不知道有什么library可以
直接用的CDF function?谢谢。
z*****h
发帖数: 17
39
来自主题: Statistics版 - 求教: R function
用惯SAS,搞不清R的function怎莫用。恳请大虾帮助。th 是一组有30个变量的variable
, 想对每个th用optimize function.下面的程序无法运行,请高手帮忙改一下。万分感
谢!!!
for(i in 1:30){
f<-function(th[i],a) (th[i]-a)^2
thmin[i]<-optimize(f, c(0,1), a=1/i)
}
a********a
发帖数: 346
40
x=function(n){
sim=rnorm(n)
return(sim)
}
x(n=10)
> x(n=10)
[1] 0.3466314 0.7477493 1.1274950 0.3848275 0.9549582 1.1843009
[7] 0.3804086 -1.4802425 1.4219162 1.5410326
> sim
Error: object 'sim' not found
I generate dataset 'sim' from a R function. As you can see from the result,
I can see the data I generated, but why the sim could not be found? As I
can not get sim, so I can not save the data as a text file. Do you know how
to save a dataset generated within a function?
Thanks
d*******1
发帖数: 854
41
我只知道TAPPLY(A,B,FUNCTION(X)(XXXXXXXXXXXXXXXX)), 但是能不能用TAPPLY包裹一
个含两个参数的FUNCTION 类似 TAPPLY(XXXXXXXXXXX, FUNCTION(X,Y)(XXXXXYYYYYY))
谢了.
a******n
发帖数: 11246
42
对于target variable是0,1的情况,我们通常用logit作为link function。那么如何决
定要不要用别的比如probit, inverse logit等link function呢?换句话说,用不同
link function build了几个model,如何比较好坏?多谢!
p****e
发帖数: 165
43
这两天就要面试了,会有一个面试官现场问问Excel function, 我有两年Analyst经验
,但都是用SQL和BI tool来做Dashboard, 会基本的Excel function, 比如vlookup,
pivot table. 这两天时间我怎样才能最大效率地利用时间应对Excel现场面试?因为时
间有限,我想着重准备以下这些在实际工作中比较好用的Excel Function:
1. LOOKUP系列 (Vlookup, Hlookup等)
2. Offset
3. Match
4. countif, sumif
想问问版上给位大侠还有什么补充?不甚感激!
l*****0
发帖数: 299
44
simultaneous和nonsimultaneous confidence bounds for function的区别?
在regression(curve fitting)中,simultaneous和nonsimultaneous confidence
bounds for function的区别是什么?请注意是confidence bounds for function不是
confidence bounds for future observations. matlab里有简短的解释,但很不清楚。
谢谢!
m******t
发帖数: 273
45
Hi,
I need to solve a problem about predicting values of some numerical vectors
by using other numerical vectors with all these vectors in the same vector
set, which is generated by one or more black box functions.
Given a vector space:
P =[S_1, S_2, …, S_T | Sk is a vector of q numbers, k = 1, ..., T]
Find a sub-group of vectors g = {S_d | d belongs to 1, …, T } and a
function h( S_d )
Such that
Difference between the value of h(S_g) and S_r is minimized
set g + set r = set P
... 阅读全帖
m******u
发帖数: 277
46
来自主题: Statistics版 - SAS Macro Function
请问大家平时用SAS Macro function吗?比如%eval, %SYMPUT之类的?
今天有个面试问到关于Macro,我只回答如何自己编写Macro,如何使用。
没有回答出SAS现有的那些macro function...不知道那些function大家平常用的多吗?
谢谢。
m******u
发帖数: 277
47
来自主题: Statistics版 - SAS Macro Function
是嗫是嗫~ 我倒是会用一些SAS function,比如substr, compress之类的,但是macro
function感觉有点节外生枝,跟普通的function不带%符号的,有啥区别啊?
y*****w
发帖数: 1350
48
来自主题: Statistics版 - 请问如何在R中写recursive function?
就是如何写iterations。比如我需要得到如下function的运算结果:
f(x) = p*f(x-1), x>=1, p=constant
到最下面时比如x=1, 则f()有固定的distribution或者直接f(0)=constant。
如果我直接在R中输入如上f(x) = p*f(x-1)运行,R会告诉我“could not find
function f”。
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~
上面是一个parameter的情况。如果我有两个parameters,比如下面这个recursive
function,应该如何表达呢?是不是必须用到matrix?
f(s,d) = p*f(s-1,d) + q*f(s,d-1), s>=0, d>=0, p=constant, q=constant, f(0,0)
=constant
w*******y
发帖数: 60932
49
I was looking for Remote extender for my AV system so I can move all my
devices to cabinet and have wire-free family room. I was going to buy this
Remote Control Extender for $19.99 and saw this combo deal. This Windows 7
remote was included in combo price for only $5 more.
1. Rosewill RRC-126 Windows 7 Certified Media Center Infrared Remote Control
with Netflix Function
* Microsoft Windows7&Vista certification and Green Button support
* 48 button remote
* Netflix function
* Include all of the b... 阅读全帖
w*******y
发帖数: 60932
50
Columbia Multi-Function Tool & Torch Light Set:
http://www.kohls.com/kohlsStore/clearance/men/gadgets/PRD~89315 MultiFunction Tool and Torch Light Set.jsp
now $6.00
original $30.00
code JINGLE2078 for 20% off
free shipping code GIFT4KC
Prepare for any expedition with Columbia. This compact multifunction tool
and flashlight give you handy assistance through your outdoor adventures.
Part of a full selection of useful gear at Kohl's.
Textured surface allows a firm grip.
LED light stays bright for a... 阅读全帖
首页 上页 1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)