c6748浮点计算需要调用什么头文件 - 第2页 - TMS320C6748 - 嵌入式开发者社区 - 51ele.net
设为首页收藏本站

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

12
返回列表 发新帖
楼主: 369821854

c6748浮点计算需要调用什么头文件

[复制链接]

44

主题

81

帖子

1416

积分

金牌会员

Rank: 6Rank: 6

积分
1416
发表于 2018-10-22 10:42:50 | 显示全部楼层

你好,你说的math例程是 指的那个例程呢?我购买6748开发板时,里面带光盘里的资料好像不全,没发现math例程。麻烦告知一下,谢谢。

点评

/****************************************************************************/ /* */ /* 数学函数库测试 基本运算  详情 回复 发表于 2019-5-21 15:01
回复 支持 反对

使用道具 举报

15

主题

1357

帖子

4579

积分

创龙

Rank: 8Rank: 8

积分
4579
发表于 2019-5-21 15:01:02 | 显示全部楼层
zss 发表于 2018-10-22 10:42
你好,你说的math例程是 指的那个例程呢?我购买6748开发板时,里面带光盘里的资料好像不全,没发现math ...

/****************************************************************************/
/*                                                                          */
/*              数学函数库测试 基本运算                                     */
/*                                                                          */
/*              2014年09月03日                                              */
/*                                                                          */
/****************************************************************************/
// 注意:sp 后缀的函数是单精度浮点运算
//      dp 后缀的函数是双精度浮点运算
// 部分函数并没有默认被编译到库中
// Mathlib 跟 FastRTS 的主要区别是 Mathlib 是浮点运算对浮点 DSP 指令优化
//                                 FastRTS 是浮点运算对定点 DSP 指令优化

#include <stdio.h>                  // C 语言标准输入输出函数库
#include <math.h>                   // C 数学函数库
#include <mathf.h>                  // C 数学函数库 浮点

#include "mathlib.h"                // DSP 数学函数库

/****************************************************************************/
/*                                                                          */
/*              宏定义                                                      */
/*                                                                          */
/****************************************************************************/
// 软件断点
#define SW_BREAKPOINT     asm(" SWBP 0 ");

/****************************************************************************/
/*                                                                          */
/*              全局变量                                                    */
/*                                                                          */
/****************************************************************************/

/****************************************************************************/
/*                                                                          */
/*              函数声明                                                    */
/*                                                                          */
/****************************************************************************/

/****************************************************************************/
/*                                                                          */
/*              主函数                                                      */
/*                                                                          */
/****************************************************************************/
int main(void)
{
        printf("\n");

        // 除法
        printf("除法 单精度 2/3 = %f / 3/2 = %f \n", divsp(2, 3), divsp(3, 2));
        printf("除法 双精度 2/3 = %f / 3/2 = %f \n", divsp(2, 3), divsp(3, 2));

        // 返回小于或者等于指定表达式的最大整数
        printf("返回小于或者等于指定表达式的最大整数 RTS 库 %f \n", floorf(1.5));

        // 返回大于或者等于指定表达式的最小整数
        printf("返回大于或者等于指定表达式的最小整数 RTS 库 %f \n", ceilf(1.5));

        // 绝对值
        printf("绝对值 RTS 库 1.5 %f / -1.5 %f \n", fabsf(1.5), fabsf(-1.5));

        // 余数
        printf("余数 RTS 库 4.5 %% 3 %f \n", fmodf(4.5, 3));

        // 幂
        printf("幂 单精度 2^3 = %f / 2^1.5 = %f \n", powsp(2, 3), powsp(2, 1.5));
        printf("幂 双精度 2^3 = %f / 2^1.5 = %f \n", powdp(2, 3), powdp(2, 1.5));
        printf("幂 RTS 库 2^3 = %f / 2^1.5 = %f \n", powf(2, 3), powf(2, 1.5));

        // 倒数
        printf("倒数 单精度 0.5 %f \n", recipsp(0.5));
        printf("倒数 双精度 0.5 %f \n", recipsp(0.5));

        // 开方
        printf("开方 单精度 3^2 + 4^2 %f \n", sqrtsp(3 * 3 + 4 *4));
        printf("开方 双精度 3^2 + 4^2 %f \n", sqrtdp(3 * 3 + 4 *4));
        printf("开方 RTS 库 3^2 + 4^2 %f \n", sqrtf(3 * 3 + 4 *4));

        // 开方 倒数
        printf("开方 倒数 单精度 3^2 + 4^2 %f \n", rsqrtsp(3 * 3 + 4 *4));
        printf("开方 倒数 双精度 3^2 + 4^2 %f \n", rsqrtdp(3 * 3 + 4 *4));

        // 对数
        printf("对数 以2为底 单精度 4 %f \n", log2sp(4));
        printf("对数 以2为底 双精度 4 %f \n", log2dp(4));
        printf("对数 以2为底 RTS 库 4 %f \n", log2f(4));

        printf("对数 以e为底 单精度 e^2 %f \n", logsp(2.71828 * 2.71828));
        printf("对数 以e为底 双精度 e^2 %f \n", logdp(2.71828 * 2.71828));

        printf("对数 以10为底 单精度 100 %f \n", log10sp(100));
        printf("对数 以10为底 双精度 100 %f \n", log10dp(100));
        printf("对数 以10为底 RTS 库 100 %f \n", log10f(100));

        // 指数
        printf("指数 以2为底 单精度 4 %f \n", exp2sp(4));
        printf("指数 以2为底 双精度 4 %f \n", exp2dp(4));
        printf("指数 以2为底 RTS 库 4 %f \n", exp2f(4));

        printf("指数 以e为底 单精度 4 %f \n", expsp(2));
        printf("指数 以e为底 双精度 4 %f \n", expdp(2));

        printf("指数 以10为底 单精度 4 %f \n", exp10sp(4));
        printf("指数 以10为底 双精度 4 %f \n", exp10dp(4));
        printf("指数 以10为底 RTS 库 4 %f \n", exp10f(4));

        // 三角函数 参数弧度
        // π = 6arcsin(1/2)
        printf("正弦 单精度 sin(π/6) %f \n", sinsp(6 * asin(0.5) / 6));
        printf("正弦 双精度 sin(π/6) %f \n", sindp(6 * asin(0.5) / 6));
        printf("正弦 RTS 库 sin(π/6) %f \n", sinf(6 * asin(0.5) / 6));

        printf("余弦 单精度 cos(π/3) %f \n", cossp(6 * asin(0.5) / 3));
        printf("余弦 双精度 cos(π/3) %f \n", cosdp(6 * asin(0.5) / 3));
        printf("余弦 RTS 库 cos(π/3) %f \n", cosf(6 * asin(0.5) / 3));

        printf("正切 RTS 库 tan(π/4) %f \n", tanf(6 * asin(0.5) / 4));

        // 双曲函数 参数弧度
        // π = 6arcsin(1/2)
        printf("双曲函数 单精度 恒等式 cosh(x)^2 - sinh(x)^2 = 1 %f \n", pow(coshf(6 * asin(0.5) / 6), 2) - pow(sinhf(6 * asin(0.5) / 6), 2));

        printf("注意:部分函数并没有默认被编译到数学函数库");

        // 断点
        SW_BREAKPOINT;
}
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|手机版|小黑屋|嵌入式开发者社区 ( 粤ICP备15055271号

GMT+8, 2024-3-29 12:43 , Processed in 0.036810 second(s), 23 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

快速回复 返回顶部 返回列表