clapack在android上移植
参考
https://www.cnblogs.com/hrlnw/p/4128217.html
1.从https://github.com/simonlynen/android_libs这个网址下载代码。
如何在android上进行android库编译
https://blog.csdn.net/h3c4lenovo/article/details/10364679
1 设置ndk环境
export ANDROID_NDK_HOME=/DATA/Android/Ndk/android-ndk-r13b
export PATH=$PATH:$ANDROID_NDK_HOME
#ANDROID_NDK_HOME=/DATA/share/software/android-ndk-r16
2 make 与gcc确保无问题
make -v
gcc -v
3 写好jni文件
4 编译ndk-build
5 android工程调用
#如果同时编译32和64未版本,或会导致32位的库打包到64位中,需要单独编译,
#./obj/local/arm64-v8a/libtestlapack.so: error adding symbols: File in wrong format
导致32位的库打包到64位中,
[arm64-v8a] Prebuilt : libtestlapack.so <= jni/lapack/lib/armeabi-v7a/
[arm64-v8a] Install : libtestlapack.so => libs/arm64-v8a/libtestlapack.so
[arm64-v8a] Compile++ : mtcnn_facedetect <= similaritytrans.cpp
#include <stdio.h>
#include <string.h>
#include <jni.h>
#include <complex>
#include <sstream>
#include <string>
#include <android/log.h>
#define TAG "log"
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,TAG ,__VA_ARGS__) // #ifndef JNIEXPORT
// #define JNIEXPORT
// #endif // #ifndef JNICALL
// #define JNICALL
// #endif static long dgesvd(char *jobu, char *jobvt, long *m, long *n,
double *a, long *lda, double *s, double *u, long *
ldu, double *vt, long *ldvt, double *work, long *lwork)
{
// int dgesvd_(char *jobu, char *jobvt, integer *m, integer *n,
// doublereal *a, integer *lda, doublereal *s, doublereal *u, integer *
// ldu, doublereal *vt, integer *ldvt, doublereal *work, integer *lwork,
// integer *info) extern int dgesvd_(char *jobu, char *jobvt, long *m, long *n,
double *a, long *lda, double *s, double *u, long *
ldu, double *vt, long *ldvt, double *work, long *lwork,
long *info); long info;
dgesvd_("A", "A", m, n, a, lda, s, u, ldu, vt, ldvt, work, lwork, &info);
return info;
} #define mymax(a,b) (a) > (b) ? (a) : (b)
#define mymin(a,b) (a) < (b) ? (a) : (b) void transposeMatrix(double *A, int row, int col)
{
for(int i =; i < row; ++i)
{
for (int j = i; j < col; ++j)
{
double temp = A[i * col + j];
A[i * col + j] = A[j * col + i];
A[j *col + i] = temp;
}
}
} int GetLapackSVD(double *a, double *u, double *s, double *vt)
{
//double a[2*2] = {4 , 4 , -3 , 3};
//这个函数,这里要特别注意储存方式(column major)!!
transposeMatrix(a,,);
long m,n;
long lda,ldu,ldvt,lwork;
m = ;
n = ;
lda = ;
ldu = ;
ldvt = ;
//https://blog.csdn.net/versuna/article/details/8246377
lwork = ;//mymax(3*mymin(m, n)+mymax(m, n), 5*mymin(m,n));
LOGD("#lwork = %d", lwork);
double work[*lwork];
char jobu = 'A';
char jobvt = 'A';
dgesvd(&jobu, &jobvt, &m, &n, a, &lda, s, u, &ldu, vt, &ldvt, work, &lwork);
return ;
} int main()
{
double a[];
double u[];
double s[];
double vt[];
}
在贴一段内部代码
/*****************************************************************************
Copyright (c) 2014, Intel Corp.
All rights reserved. Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of Intel Corporation nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
THE POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************
* Contents: Native high-level C interface to LAPACK function dgesdd
* Author: Intel Corporation
* Generated November 2015
*****************************************************************************/ #include "lapacke_utils.h" lapack_int LAPACKE_dgesdd( int matrix_layout, char jobz, lapack_int m,
lapack_int n, double* a, lapack_int lda, double* s,
double* u, lapack_int ldu, double* vt,
lapack_int ldvt )
{
lapack_int info = ;
lapack_int lwork = -;
lapack_int* iwork = NULL;
double* work = NULL;
double work_query;
if( matrix_layout != LAPACK_COL_MAJOR && matrix_layout != LAPACK_ROW_MAJOR ) {
LAPACKE_xerbla( "LAPACKE_dgesdd", - );
return -;
}
#ifndef LAPACK_DISABLE_NAN_CHECK
if( LAPACKE_get_nancheck() ) {
/* Optionally check input matrices for NaNs */
if( LAPACKE_dge_nancheck( matrix_layout, m, n, a, lda ) ) {
return -;
}
}
#endif
/* Allocate memory for working array(s) */
iwork = (lapack_int*)
LAPACKE_malloc( sizeof(lapack_int) * MAX(,*MIN(m,n)) );
if( iwork == NULL ) {
info = LAPACK_WORK_MEMORY_ERROR;
goto exit_level_0;
}
/* Query optimal working array(s) size */
info = LAPACKE_dgesdd_work( matrix_layout, jobz, m, n, a, lda, s, u, ldu, vt,
ldvt, &work_query, lwork, iwork );
if( info != ) {
goto exit_level_1;
}
lwork = (lapack_int)work_query;
/* Allocate memory for work arrays */
work = (double*)LAPACKE_malloc( sizeof(double) * lwork );
if( work == NULL ) {
info = LAPACK_WORK_MEMORY_ERROR;
goto exit_level_1;
}
/* Call middle-level interface */
info = LAPACKE_dgesdd_work( matrix_layout, jobz, m, n, a, lda, s, u, ldu, vt,
ldvt, work, lwork, iwork );
/* Release memory and exit */
LAPACKE_free( work );
exit_level_1:
LAPACKE_free( iwork );
exit_level_0:
if( info == LAPACK_WORK_MEMORY_ERROR ) {
LAPACKE_xerbla( "LAPACKE_dgesdd", info );
}
return info;
}
clapack在android上移植的更多相关文章
- 将 Android 应用移植到 BlackBerry PlayBook 上
美国西部时间18号早上,也就是我们的19号凌晨,BlackBerry DevCon活动隆重举行,PlayBook 2.0开发测试版随之发布.PlayBook 2.0的一个重要功能就是支持Android ...
- FFmpeg在Android上的移植之第一步
http://blog.sina.com.cn/s/blog_69a04cf40100x1fr.html 从事多媒体软件开发的人几乎没有不知道FFmpeg的,很多视频播放器都是基于FFmpeg开发的. ...
- Android系统移植(一)-让android系统在目标平台上运行起来
编号),文件系统采用ubifs格式,控制台设备为ttyS1,波特率为115200 启动的第一个应用程序是/init (6)确保控制台的设置和硬件保持一致,如:硬件上串口用的是UART1,则内核启动参数 ...
- FFmpeg在Android上的移植优化步骤
http://blog.csdn.net/feixiang_john/article/details/7894188 从事多媒体软件开发的人几乎没有不知道FFmpeg的,很多视频播放器都是基于FFmp ...
- 系列篇|编译可在Android上运行的依赖库(一):glib库
前言 这是系列文章,它们由<编译可在Android上运行的glib库>及其他4篇文章组成,这4篇文章在“编译依赖库”一节中列出.由于glib库依赖于其他第三方库,所以需要先将依赖的第三方库 ...
- 第一章 Android系统移植与驱动开发概述
本书第一章首先简单概要地介绍了关于Android系统移植和驱动开发的相关内容. 所谓“移植”是指为特定的自己的设备,如手机定制Android的过程.自己开发一些程序(移植)装载在设备上,使得Andro ...
- 浅谈Android系统移植、Linux设备驱动
一.Android系统架构 第一层:Linux内核 包括驱动程序,管理内存.进程.电源等资源的程序 第二层:C/C++代码库 包括Linux的.so文件以及嵌入到APK程序中的NDK代码 第三层:An ...
- 第一章Android系统移植与驱动开发概述--读书笔记
以前,初步学习过嵌入式Linux驱动开发的基础课程,对于驱动开发可以说是有了一点点微末的基础吧.首先我们要对Android嵌入式系统有一个初步的认识,Android系统发展到今天已经具备了完善的架构. ...
- Android深度探索HAL和驱动开发(卷1) 第一章 Android系统移植和驱动开发
由于Android是基于Linux内核的,因此,Android和其他Linux系统的核心部分差异非常小.然而不同版本的Android使用的Linux内核的版本有细微的差异,所以不同Android驱动可 ...
随机推荐
- [na]tcp&udp层各协议小结
TCP和UDP 传输层功能: 可靠性:序列号.确认号&flag位 有效性:win滑动窗口 这篇目录索引: Tcp可靠性 Tcp流控 Tcp拥塞控制 Tcp运输连接管理 TCP的可靠性和流控 为 ...
- WCF返回null超时
Message.CreateMessage(msg.Version, msg.Headers.Action + "Response", DealObject("错误信息& ...
- 【Unity】第7章 输入控制
分类:Unity.C#.VS2015 创建日期:2016-04-21 一.简介 Unity提供了-个非常易用和强大的用于处理输入信息的类:Input,利用该类可以处理鼠标.键盘.摇杆/方向盘/手柄等游 ...
- 【Unity】3.0 第3章 创建和导入3D模型
分类:Unity.C#.VS2015 创建日期:2016-04-02 一.简介 利用Unity内置的基本模型和工具,不需要借助任何其他的三维建模软件,就可以直接创建出各种3D模型,这是这一章我们首先学 ...
- (转)用stunnel给普通http通信加密
转自:https://www.digitalocean.com/community/tutorials/how-to-set-up-an-ssl-tunnel-using-stunnel-on-ubu ...
- Lua string.gsub (s, pattern, repl [, n])
lua的string函数导出在string module中.在lua5.1,同时也作为string类型的成员方法,因此,我们既可以写成string.gsub (s,……), 也可以s:gsub(). ...
- RIFF格式简介
Resource Interchange File Format(简称RIFF),资源交换文件格式,是一种按照标记区块存储数据(tagged chunks)的通用文件存储格式,多用于存储音频.视频等多 ...
- Linux screen用法简介
[admin@VM_0_2_centos ~]$ screen -bash: screen: 未找到命令 [admin@VM_0_2_centos ~]$ sudo su [sudo] passwor ...
- Oracle 大小写转换函数
Oracle 大小写转换函数 转大写UPPER 转小写LOWER 测试: select UPPER('Test') as u from dual; select LOWER('Test') as l ...
- CentOS7下查询硬件信息
原文:https://blog.csdn.net/pwb1994001/article/details/80896267 因为个人需要,整理的 参考:https://blog.csdn.net/dre ...