Objective-C/cocoa-touch 中有哪些对数函数/方法?

发布于 2024-07-22 06:21:44 字数 712 浏览 10 评论 0原文

我尝试过搜索对数+ Objective-C,但我得到的只是老师提供的数学测试页,或者解释什么是对数;)

我得到了一些类似于 83912.41234 的测量结果,其他的是 32.94232。 我需要将这个巨大的频谱压缩到 0 到 100 之间,并且 32.94232 必须至少大于 2,其中 83912.41234 将接近 100。所以我认为对数函数将是我的朋友。

更新: 我通过“快速打开”(Xcode 中非常好的命令:SHIFT + CMD + D)遇到了 math.h 文件,然后,大吃一惊:

extern double log ( double );
extern float logf ( float );

extern double log10 ( double );
extern float log10f ( float );

extern double log2 ( double );
extern float log2f ( float );

extern double log1p ( double );
extern float log1pf ( float );

extern double logb ( double );
extern float logbf ( float );

但是:没有文字,没有注释。 我不是一个数学狂。 因此,一些描述会很好,例如,什么情况下需要什么样的对数,曲线是什么样子等等......所以任何好的链接都将受到高度赞赏!

I've tried searching for logarithm + objective-c, but all I get is math test pages from teachers, or explanations what a logarithm is ;)

I've got some measurements that are like 83912.41234 and others are 32.94232. I need to press down this huge spectrum into something between 0 and 100, and that 32.94232 would habe to be at least something bigger than 2, where the 83912.41234 would be something near 100. So I think a logarithm function will be my friend here.

UPDATE:
I've came across the math.h file through "Open Quickly" (very nice command in Xcode: SHIFT + CMD + D), and there, big surprise:

extern double log ( double );
extern float logf ( float );

extern double log10 ( double );
extern float log10f ( float );

extern double log2 ( double );
extern float log2f ( float );

extern double log1p ( double );
extern float log1pf ( float );

extern double logb ( double );
extern float logbf ( float );

But: No text, no comments. I'm not such a math-freak. So some description would be good, i.e. what kind of logarithm for what case, how the curve looks like, etc... so any great links are highly appreciated!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

太阳公公是暖光 2024-07-29 06:21:44

另外,获取任意底数的对数:

float logx(float value, float base) 
{
   return log10f(value) / log10f(base);
}

Also, getting a logarithm with an arbitrary base:

float logx(float value, float base) 
{
   return log10f(value) / log10f(base);
}
携余温的黄昏 2024-07-29 06:21:44

math.h 是一个标准包含。 wikipedia 页面有一些文档。

“压缩”值的另一种方法是将值拟合成一条直线。 对于您的示例:

直线方程

y = mx + c
y = 'squished' value.
x = The value you want to squish
m = Gradient of the line
c = intercept on the y axis

对您的值的快速计算给出如下内容:

y = 1.17e-3 x + 1.96

希望这有帮助。

math.h is a standard include. the wikipedia page has some documentation.

Another way to 'squish' the values is to fit your values to a straight line. For you example:

Straight line equation

y = mx + c
y = 'squished' value.
x = The value you want to squish
m = Gradient of the line
c = intercept on the y axis

A quick calculation on your values gives something like:

y = 1.17e-3 x + 1.96

Hope this helps.

蘸点软妹酱 2024-07-29 06:21:44

买一本关于 C 标准库函数的书怎么样?

否则,您可以尝试手册页:
例如,man 3 logf

How about grabbing a book on C standard library functions?

Otherwise, you can try man pages:
man 3 logf, for example

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文