/** * * \section COPYRIGHT * * Copyright 2013-2014 The srsLTE Developers. See the * COPYRIGHT file at the top-level directory of this distribution. * * \section LICENSE * * This file is part of the srsLTE library. * * srsLTE is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation, either version 3 of * the License, or (at your option) any later version. * * srsLTE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * A copy of the GNU Lesser General Public License can be found in * the LICENSE file in the top-level directory of this distribution * and at http://www.gnu.org/licenses/. * */ #include #include #include "srslte/common/phy_common.h" #include "srslte/mex/mexutils.h" #include "srslte/utils/vector.h" bool mexutils_isScalar(const mxArray *ptr) { return mxGetM(ptr) == 1 && mxGetN(ptr) == 1; } char *mexutils_get_char_struct(const mxArray *ptr, const char *field_name) { mxArray *p; p = mxGetField(ptr, 0, field_name); if (!p) { return NULL; } if (mxIsCell(p)) { return mxArrayToString(mxGetCell(p,0)); } else { return mxArrayToString(p); } } int mexutils_read_uint32_struct(const mxArray *ptr, const char *field_name, uint32_t *value) { mxArray *p; p = mxGetField(ptr, 0, field_name); if (!p) { return -1; } *value = (uint32_t) mxGetScalar(p); return 0; } int mexutils_read_float_struct(const mxArray *ptr, const char *field_name, float *value) { mxArray *p; p = mxGetField(ptr, 0, field_name); if (!p) { return -1; } *value = (float) mxGetScalar(p); return 0; } int mexutils_read_cell(const mxArray *ptr, srslte_cell_t *cell) { if (mexutils_read_uint32_struct(ptr, "NCellID", &cell->id)) { return -1; } if (mexutils_read_uint32_struct(ptr, "CellRefP", &cell->nof_ports)) { return -1; } if (mexutils_read_uint32_struct(ptr, "NDLRB", &cell->nof_prb)) { return -1; } // TODO cell->cp = SRSLTE_CP_NORM; cell->phich_length = SRSLTE_PHICH_NORM; cell->phich_resources = SRSLTE_PHICH_SRSLTE_PHICH_R_1_6; return 0; } int mexutils_read_cf(const mxArray *ptr, cf_t **buffer) { int numelems = mxGetNumberOfElements(ptr); cf_t *tmp = srslte_vec_malloc(numelems * sizeof(cf_t)); if (tmp) { double *inr=mxGetPr(ptr); double *ini=mxGetPi(ptr); for (int i=0;i