Austin Schuh | 9a24b37 | 2018-01-28 16:12:29 -0800 | [diff] [blame^] | 1 | /************************************************************************************************** |
| 2 | * * |
| 3 | * This file is part of BLASFEO. * |
| 4 | * * |
| 5 | * BLASFEO -- BLAS For Embedded Optimization. * |
| 6 | * Copyright (C) 2016-2017 by Gianluca Frison. * |
| 7 | * Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * |
| 8 | * All rights reserved. * |
| 9 | * * |
| 10 | * HPMPC is free software; you can redistribute it and/or * |
| 11 | * modify it under the terms of the GNU Lesser General Public * |
| 12 | * License as published by the Free Software Foundation; either * |
| 13 | * version 2.1 of the License, or (at your option) any later version. * |
| 14 | * * |
| 15 | * HPMPC is distributed in the hope that it will be useful, * |
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * |
| 18 | * See the GNU Lesser General Public License for more details. * |
| 19 | * * |
| 20 | * You should have received a copy of the GNU Lesser General Public * |
| 21 | * License along with HPMPC; if not, write to the Free Software * |
| 22 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * |
| 23 | * * |
| 24 | * Author: Gianluca Frison, giaf (at) dtu.dk * |
| 25 | * gianluca.frison (at) imtek.uni-freiburg.de * |
| 26 | * * |
| 27 | **************************************************************************************************/ |
| 28 | |
| 29 | #include <stdlib.h> |
| 30 | #include <stdio.h> |
| 31 | #include <math.h> |
| 32 | |
| 33 | #include "../include/blasfeo_common.h" |
| 34 | |
| 35 | |
| 36 | |
| 37 | #if defined(LA_REFERENCE) | defined(LA_BLAS) |
| 38 | |
| 39 | |
| 40 | |
| 41 | |
| 42 | void m_cvt_d2s_strvec(int m, struct d_strvec *vd, int vdi, struct s_strvec *vs, int vsi) |
| 43 | { |
| 44 | double *pd = vd->pa+vdi; |
| 45 | float *ps = vs->pa+vsi; |
| 46 | int ii; |
| 47 | for(ii=0; ii<m; ii++) |
| 48 | { |
| 49 | ps[ii] = (float) pd[ii]; |
| 50 | } |
| 51 | return; |
| 52 | } |
| 53 | |
| 54 | |
| 55 | |
| 56 | void m_cvt_s2d_strvec(int m, struct s_strvec *vs, int vsi, struct d_strvec *vd, int vdi) |
| 57 | { |
| 58 | double *pd = vd->pa+vdi; |
| 59 | float *ps = vs->pa+vsi; |
| 60 | int ii; |
| 61 | for(ii=0; ii<m; ii++) |
| 62 | { |
| 63 | pd[ii] = (double) ps[ii]; |
| 64 | } |
| 65 | return; |
| 66 | } |
| 67 | |
| 68 | |
| 69 | |
| 70 | void m_cvt_d2s_strmat(int m, int n, struct d_strmat *Md, int mid, int nid, struct s_strmat *Ms, int mis, int nis) |
| 71 | { |
| 72 | int lda = Md->m; |
| 73 | int ldb = Ms->m; |
| 74 | double *pA = Md->pA+mid+nid*lda; |
| 75 | float *pB = Ms->pA+mis+nis*ldb; |
| 76 | int ii, jj; |
| 77 | for(jj=0; jj<n; jj++) |
| 78 | { |
| 79 | for(ii=0; ii<m; ii++) |
| 80 | { |
| 81 | pB[ii+jj*ldb] = (float) pA[ii+jj*lda]; |
| 82 | } |
| 83 | } |
| 84 | return; |
| 85 | } |
| 86 | |
| 87 | |
| 88 | |
| 89 | void m_cvt_s2d_strmat(int m, int n, struct s_strmat *Ms, int mis, int nis, struct d_strmat *Md, int mid, int nid) |
| 90 | { |
| 91 | int lda = Ms->m; |
| 92 | int ldb = Md->m; |
| 93 | float *pA = Ms->pA+mis+nis*lda; |
| 94 | double *pB = Md->pA+mid+nid*ldb; |
| 95 | int ii, jj; |
| 96 | for(jj=0; jj<n; jj++) |
| 97 | { |
| 98 | for(ii=0; ii<m; ii++) |
| 99 | { |
| 100 | pB[ii+jj*ldb] = (double) pA[ii+jj*lda]; |
| 101 | } |
| 102 | } |
| 103 | return; |
| 104 | } |
| 105 | |
| 106 | |
| 107 | |
| 108 | #else |
| 109 | |
| 110 | #error : wrong LA choice |
| 111 | |
| 112 | #endif |