void UlamTypePrimitive::genUlamTypeAutoWriteDefinitionForC(File * fp) { //scalar and entire PACKEDLOADABLE array handled by base class write method if(!isScalar()) { // writes an element of array //3rd argument generated for compatibility with underlying method m_state.indent(fp); fp->write("void writeArrayItem(const "); fp->write(getArrayItemTmpStorageTypeAsString().c_str()); //s32 or u32 fp->write("& v, const u32 index, const u32 itemlen) { "); fp->write("UlamRef<EC>("); fp->write("*this, index * itemlen, "); //rel offset fp->write("itemlen, NULL, UlamRef<EC>::PRIMITIVE)."); //itemlen, primitive effself fp->write(writeArrayItemMethodForCodeGen().c_str()); fp->write("(v); }"); GCNL; } if(isScalar() || WritePacked(getPackable())) { // write must be scalar; ref param to avoid excessive copying //not an array m_state.indent(fp); fp->write("void"); fp->write(" write(const "); fp->write(getTmpStorageTypeAsString().c_str()); //u32, u64, or BV96 fp->write("& targ) { UlamRef<EC>::"); fp->write(writeMethodForCodeGen().c_str()); fp->write("(targ); /* entire */ }"); GCNL; } } //genUlamTypeAutoWriteDefinitionForC
void UlamTypePrimitive::genUlamTypeAutoReadDefinitionForC(File * fp) { //scalar and entire PACKEDLOADABLE array handled by base class read method if(!isScalar()) { //reads an item of array; //2nd argument generated for compatibility with underlying method m_state.indent(fp); fp->write("const "); fp->write(getArrayItemTmpStorageTypeAsString().c_str()); //s32 or u32 fp->write(" readArrayItem("); fp->write("const u32 index, const u32 itemlen) const { return "); fp->write("UlamRef<EC>("); fp->write("*this, index * itemlen, "); //rel offset fp->write("itemlen, NULL, UlamRef<EC>::PRIMITIVE)."); //itemlen, primitive effself fp->write(readArrayItemMethodForCodeGen().c_str()); fp->write("(); }"); GCNL; } if(isScalar() || WritePacked(getPackable())) { // write must be scalar; ref param to avoid excessive copying //not an array m_state.indent(fp); fp->write("const "); fp->write(getTmpStorageTypeAsString().c_str()); //u32, u64, or BV96 fp->write(" read() const { "); fp->write("return "); fp->write("UlamRef<EC>::"); fp->write(readMethodForCodeGen().c_str()); //just the guts fp->write("(); /* entire */ }"); GCNL; } } //genUlamTypeAutoReadDefinitionForC
bool getFloat(iop::float64& fltTarget, ahm::PropertyValue *pSource) { if(isScalar(pSource)) { switch(pSource->derivedType()) { case ahm::PropertyValue::TYPE_INT: { ahm::PropertyValueInt* pIntValueSource = (ahm::PropertyValueInt*)pSource; fltTarget = pIntValueSource->getValue(); return true; } case ahm::PropertyValue::TYPE_FLOAT: { ahm::PropertyValueFloat* pFloatValueSource = (ahm::PropertyValueFloat*)pSource; fltTarget = pFloatValueSource->getValue(); return true; } } } return false; }
void UlamTypePrimitive::genUlamTypeWriteDefinitionForC(File * fp) { u32 totbitsize = getTotalBitSize(); if(totbitsize <= BITSPERATOM) //Big 96bit array is unpacked, but.. (t3969) { m_state.indent(fp); fp->write("void write"); fp->write("(const "); fp->write(getTmpStorageTypeAsString().c_str()); //s32 or u32, s64 or u64 fp->write("& v) { BVS::"); fp->write(writeMethodForCodeGen().c_str()); fp->write("(0u, "); fp->write_decimal_unsigned(totbitsize); //incl WriteBig if(isScalar()) { fp->write("u, v); }"); GCNL; } else { fp->write("u, v); } //writes entire array"); GCNL; } } else { //UNPACKED m_state.indent(fp); fp->write("void "); fp->write(" write(const "); fp->write(getTmpStorageTypeAsString().c_str()); //BV fp->write("& bv) { BVS::"); fp->write("WriteBV(0u, bv); "); fp->write("} //writes entire BV"); GCNL; } } //genUlamTypeWriteDefinitionForC
bool setFloat(ahm::PropertyValue *pTarget, iop::float64 fltval) { if(isScalar(pTarget)) { switch(pTarget->derivedType()) { case ahm::PropertyValue::TYPE_INT: { ahm::PropertyValueInt* pIntValueTarget = (ahm::PropertyValueInt*)pTarget; pIntValueTarget->setValue((iop::int32) fltval); return true; } case ahm::PropertyValue::TYPE_FLOAT: { ahm::PropertyValueFloat* pFloatValueTarget = (ahm::PropertyValueFloat*)pTarget; pFloatValueTarget->setValue(fltval); return true; } } } return false; }
const std::string UlamType::getTmpStorageTypeAsString(s32 sizebyints) { std::string ctype; switch(sizebyints) { case 0: //e.g. empty quarks case 32: ctype = "u32"; break; case 64: ctype = "u64"; break; case 96: ctype = "BV96"; break; default: { assert(!isScalar()); //ctype = getTmpStorageTypeAsString(getItemWordSize()); //u32, u64 (inf loop) std::ostringstream cstr; if(sizebyints == (s32) getItemWordSize()) cstr << "BitVector<" << getBitSize() << ">"; else cstr << "BitVector<" << getTotalBitSize() << ">"; //entire array ctype = cstr.str(); } }; return ctype; } //getTmpStorageTypeAsString
/*--------------------------------------------------------------------------*/ int getScalarBoolean(void* _pvCtx, int* _piAddress, int* _piBool) { SciErr sciErr; sciErr.iErr = 0; sciErr.iMsgCount = 0; int iRows = 0; int iCols = 0; int* piBool = NULL; sciErr = getMatrixOfBoolean(_pvCtx, _piAddress, &iRows, &iCols, &piBool); if(sciErr.iErr) { addErrorMessage(&sciErr, API_ERROR_GET_SCALAR_BOOLEAN, _("%s: Unable to get argument #%d"), "getScalarBoolean", getRhsFromAddress(_pvCtx, _piAddress)); printError(&sciErr, 0); return sciErr.iErr; } if(isScalar(_pvCtx, _piAddress) == 0) { addErrorMessage(&sciErr, API_ERROR_GET_SCALAR_BOOLEAN, _("%s: Wrong type for input argument #%d: A scalar expected.\n"), "getScalarBoolean", getRhsFromAddress(_pvCtx, _piAddress)); printError(&sciErr, 0); return sciErr.iErr; } if(_piBool != NULL) { *_piBool = piBool[0]; } return 0; }
Variant IniSetting::Unbox(const Variant& boxed, std::set<ArrayData*>& seen, bool& use_defaults, const String& array_key) { assert(boxed.isArray()); Variant unboxed(Array::Create()); auto ad = boxed.getArrayData(); if (seen.insert(ad).second) { for (auto it = boxed.toArray().begin(); it; it.next()) { auto key = it.first(); // asserting here to ensure that key is a scalar type that can be // converted to a string. assert(key.isScalar()); auto& elem = it.secondRef(); unboxed.asArrRef().set( key, elem.isArray() ? Unbox(elem, seen, use_defaults, key.toString()) : elem ); } seen.erase(ad); } else { // The insert into seen wasn't successful. We have recursion. // break the recursive cycle, so the elements can be freed by the MM. // The const_cast is ok because we fully own the array, with no sharing. // Use the current array key to give a little help in the log message const_cast<Variant&>(boxed).unset(); use_defaults = true; Logger::Warning("INI Recursion Detected at offset named %s. " "Using default runtime settings.", array_key.toCppString().c_str()); } return unboxed; }
/*--------------------------------------------------------------------------*/ int getAllocatedSingleWideString(void* _pvCtx, int* _piAddress, wchar_t** _pwstData) { SciErr sciErr = sciErrInit(); int iRows = 0; int iCols = 0; int iLen = 0; if (isScalar(_pvCtx, _piAddress) == 0 || isStringType(_pvCtx, _piAddress) == 0) { addErrorMessage(&sciErr, API_ERROR_GET_ALLOC_SINGLE_WIDE_STRING, _("%s: Wrong type for input argument #%d: A single string expected.\n"), "getAllocatedSingleWideString", getRhsFromAddress(_pvCtx, _piAddress)); printError(&sciErr, 0); return sciErr.iErr; } sciErr = getMatrixOfWideString(_pvCtx, _piAddress, &iRows, &iCols, &iLen, NULL); if (sciErr.iErr) { addErrorMessage(&sciErr, API_ERROR_GET_ALLOC_SINGLE_WIDE_STRING, _("%s: Unable to get argument data"), "getAllocatedSingleWideString"); printError(&sciErr, 0); return sciErr.iErr; } *_pwstData = (wchar_t*)MALLOC(sizeof(wchar_t) * (iLen + 1)); //+1 for null termination sciErr = getMatrixOfWideString(_pvCtx, _piAddress, &iRows, &iCols, &iLen, _pwstData); if (sciErr.iErr) { addErrorMessage(&sciErr, API_ERROR_GET_ALLOC_SINGLE_WIDE_STRING, _("%s: Unable to get argument data"), "getAllocatedSingleWideString"); printError(&sciErr, 0); FREE(*_pwstData); return sciErr.iErr; } return 0; }
/*--------------------------------------------------------------------------*/ int checkParam(void* _pvCtx, int _iPos, char* fname) { SciErr sciErr; int* piAddr = NULL; //get var address sciErr = getVarAddressFromPosition(_pvCtx, _iPos, &piAddr); if (sciErr.iErr) { printError(&sciErr, 0); Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, _iPos); return 1; } //check is real scalar double if ( isScalar(_pvCtx, piAddr) == 0 || isDoubleType(_pvCtx, piAddr) == 0 || isVarComplex(_pvCtx, piAddr) == 1) { Scierror(999, _("%s: Wrong type for input argument #%d: An integer value expected.\n"), fname, _iPos); return 1; } return 0; }
QString DebuggerVariable::value() const { if(isScalar()) return m_value; else return i18n("Non scalar value"); }
bool Type::isPOD() const { if( const SgClassDefinition *cdef = getClassDefinition() ) // This seems to cover POD-unions, too. return isPODClass( cdef ); else return isScalar(); }
bool UlamType::checkArrayCast(UTI typidx) { if(isScalar() && m_state.isScalar(typidx)) return true; //not arrays, ok bool bOK = true; s32 arraysize = getArraySize(); s32 varraysize = m_state.getArraySize(typidx); if(arraysize != varraysize) { std::ostringstream msg; msg << "Casting different Array sizes: "; msg << m_state.getUlamTypeNameBriefByIndex(typidx).c_str(); msg << " TO " ; msg << getUlamTypeNameBrief().c_str(); MSG(m_state.getFullLocationAsString(m_state.m_locOfNextLineText).c_str(), msg.str().c_str(), ERR); bOK = false; } else { std::ostringstream msg; msg << "Casting (nonScalar) Array: "; msg << m_state.getUlamTypeNameBriefByIndex(typidx).c_str(); msg << " TO " ; msg << getUlamTypeNameBrief().c_str(); MSG(m_state.getFullLocationAsString(m_state.m_locOfNextLineText).c_str(), msg.str().c_str(), DEBUG); } return bOK; } //checkArrayCast
bool vesUniform::set(const vesVector4f &vector) { if (this->m_numberElements == 0) this->m_numberElements = 1; return isScalar() ? setElement(0, vector) : false; }
bool vesUniform::set(bool value) { if (this->m_numberElements == 0) this->m_numberElements = 1; return isScalar() ? this->setElement(0, value) : false; }
char * ScilabObjects::getSingleString(int pos, void * pvApiCtx) { SciErr err; int * addr = 0; char * str = 0; err = getVarAddressFromPosition(pvApiCtx, pos, &addr); if (err.iErr) { throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Invalid String")); } if (!isStringType(pvApiCtx, addr)) { throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("A single string expected")); } if (!isScalar(pvApiCtx, addr)) { throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("A single String expected")); } if (getAllocatedSingleString(pvApiCtx, addr, &str)) { throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Invalid String")); } return str; }
bool vesUniform::set(const vesMatrix4x4f &matrix) { if (this->m_numberElements == 0) this->m_numberElements = 1; return isScalar() ? setElement(0, matrix) : false; }
Stmt makeLoopNest(Expr tensor) { const TensorType *ttype = tensor.type().toTensor(); std::vector<Var> indices; std::vector<Expr> indicesExpr; std::vector<IndexSet> domains; for (auto &is : ttype->getOuterDimensions()) { indices.push_back(Var("index", Int)); indicesExpr.push_back(indices.back()); domains.push_back(is); } Stmt stmt; // Recursively build write statement with any inner loops if (!isScalar(ttype->getBlockType())) { stmt = makeLoopNest(TensorRead::make(tensor, indicesExpr)); } else { stmt = TensorWrite::make(tensor, indicesExpr, getZeroVal(ttype)); } // Wrap in current level loops for (int i = domains.size()-1; i >= 0; --i) { stmt = For::make(indices[i], domains[i], stmt); } return stmt; }
void PolyDDV::computeHull(PolyDDV& ddv) { if (ddv.getSize() != _types.size()) return; int i; for (i = 0; i < ddv.getSize(); ++i) { if (ddv.isPlus(i)) { if (isEq(i) || isScalar(i)) setPlus(i); else if (isMinus(i)) setStar(i); } else if (ddv.isMinus(i)) { if (isEq(i) || isScalar(i)) setMinus(i); else if (isPlus(i)) setStar(i); } else if (ddv.isStar(i)) setStar(i); else if (ddv.isScalar(i) && ! isStar(i)) { int s1 = ddv.getScalar(i); if (isScalar(i) || isEq(i)) { int s2 = 0; if (isScalar(i)) s2 = getScalar(i); if (s1 > 0 && s2 < 0 || s1 < 0 && s2 > 0) setStar(i); else if (s1 > 0 && s1 != s2) setPlus(i); else if (s1 < 0 && s1 != s2) setMinus(i); } else { if (s1 > 0 && isMinus(i) || s1 < 0 && isPlus(i)) setStar(i); } } } }
void mexFunction(int nlhs, mxArray *out[], int nrhs, const mxArray *input[]) { if (nlhs == 0) { return; } else if (nlhs != 1 || nrhs != 3) { mexErrMsgTxt("Error. Usage: [dzdx] = regionToPixel_backward(boxCount, spMap, dzdy)"); return; } // Get pointers const mxArray* boxCountMx = input[0]; const mxArray* spMapMx = input[1]; const mxArray* dzdyMx = input[2]; // Check inputs if (!mxIsDouble(boxCountMx) || !isScalar(boxCountMx)) { mexErrMsgTxt("Error: boxCount must be a scalar double!"); } if (!mxIsDouble(spMapMx) || mxGetNumberOfDimensions(spMapMx) != 2) { mexErrMsgTxt("Error: spMap must be double with format labelCount x spCount!"); } int labelCount = mxGetM(spMapMx); int spCount = mxGetN(spMapMx); const mwSize* dzdyDims = mxGetDimensions(dzdyMx); if (!mxIsSingle(dzdyMx) || dzdyDims[0] != 1 || dzdyDims[1] != 1 || dzdyDims[2] != labelCount || (!(mxGetNumberOfDimensions(dzdyMx) == 4 && dzdyDims[3] == spCount) && !(mxGetNumberOfDimensions(dzdyMx) == 3))) { mexErrMsgTxt("Error: dzdy must be single with format 1 x 1 x labelCount x spCount!"); } // Get arrays int boxCount = (int) mxGetScalar(boxCountMx); double* spMap = (double*) mxGetData(spMapMx); float* dzdy = (float*) mxGetData(dzdyMx); // Create output and initialize it to all zeros (in mxCreateNumericArray) mwSize dzdxSize[4]; dzdxSize[0] = 1; dzdxSize[1] = 1; dzdxSize[2] = labelCount; dzdxSize[3] = boxCount; out[0] = mxCreateNumericArray(4, dzdxSize, mxSINGLE_CLASS, mxREAL); float* dzdx = (float*) mxGetData(out[0]); for (int spIdx = 0; spIdx < spCount; spIdx++) { for (int labelIdx = 0; labelIdx < labelCount; labelIdx++) { // We can safely ignore the first two dimensions of these // matrices as they are always 1 int spMapIdx = labelIdx + spIdx * labelCount; double boxIdxD = spMap[spMapIdx]; int boxIdx = (int) boxIdxD - 1; // Convert from Matlab to C indexing if (!mxIsNaN(boxIdxD)) { int dzdxIdx = labelIdx + boxIdx * labelCount; dzdx[dzdxIdx] = dzdx[dzdxIdx] + dzdy[spMapIdx]; } } } }
// From IXmlSource void CTypeElement::toXml(CXmlElement &xmlElement, CXmlSerializingContext &serializingContext) const { if (!isScalar()) { xmlElement.setAttribute("ArrayLength", getArrayLength()); } base::toXml(xmlElement, serializingContext); }
bool YamlNode::equalTo(char *v) { if(isScalar()){ if(toScalar()->toString() == v){ return true; } } return false; }
// ============================================================================= int csv_isScalar(void* _pvCtx, int _iVar) { SciErr sciErr; int *piAddressVar = NULL; sciErr = getVarAddressFromPosition(pvApiCtx, _iVar, &piAddressVar); if (sciErr.iErr) { return 0; } return isScalar(pvApiCtx, piAddressVar); }
bool PlyReader::requestProperty(const std::string& elementName, const std::string& propertyName, int dataType, int dataOffset, int countType, int countOffset) { SURGSIM_ASSERT(isValid()) << "'" << m_filename << "' is an invalid .ply file"; SURGSIM_ASSERT(hasElement(elementName)) << "The element <" << elementName << "> has not been requested yet, you cannot access properties for it"; SURGSIM_ASSERT(hasProperty(elementName, propertyName)) << "The requested property <" << propertyName << "> cannot be found in element <" << elementName << ">."; bool result = false; bool scalar = isScalar(elementName, propertyName); bool wantScalar = (countType == 0); if (wantScalar && !scalar) { SURGSIM_FAILURE() << "Trying to access a list property as a scalar." << "for element <" << elementName << "> and property <" << propertyName << ">."; } else if (!wantScalar && scalar) { SURGSIM_FAILURE() << "Trying to access a scalar property as a list." << "for element <" << elementName << "> and property <" << propertyName << ">."; } if (hasProperty(elementName, propertyName) && (scalar == wantScalar)) { auto itBegin = std::begin(m_requestedElements[elementName].requestedProperties); auto itEnd = std::end(m_requestedElements[elementName].requestedProperties); bool doAdd = std::find_if(itBegin, itEnd, [propertyName](PropertyInfo p){return p.propertyName == propertyName;}) == itEnd; if (doAdd) { PropertyInfo info; info.propertyName = propertyName; info.dataType = m_data->types[dataType]; info.dataOffset = dataOffset; info.countType = m_data->types[countType]; info.countOffset = countOffset; m_requestedElements[elementName].requestedProperties.push_back(info); result = true; } } return result; }
int ScilabGateway::getsetOptions(char * fname, const int envId, ScilabAbstractOptionsSetter & setter, void * pvApiCtx) { SciErr sciErr; int * addr = 0; int val = 0; CheckInputArgument(pvApiCtx, 0, 1); CheckOutputArgument(pvApiCtx, 1, 1); ScilabAbstractEnvironment & env = ScilabEnvironments::getEnvironment(envId); ScilabGatewayOptions & options = env.getGatewayOptions(); OptionsHelper::setCopyOccured(false); ScilabObjects::initialization(env, pvApiCtx); options.setIsNew(false); if (Rhs == 0) { createScalarBoolean(pvApiCtx, 1, (int)setter.get()); LhsVar(1) = 1; PutLhsVar(); return 0; } sciErr = getVarAddressFromPosition(pvApiCtx, 1, &addr); if (sciErr.iErr) { throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Invalid variable: cannot retrieve the data")); } if (!isBooleanType(pvApiCtx, addr)) { throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Wrong type for input argument #%d: A boolean expected."), 1); } if (!isScalar(pvApiCtx, addr)) { throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Wrong type for input argument #%d: A single boolean expected."), 1); } getScalarBoolean(pvApiCtx, addr, &val); setter.set(val == 1); LhsVar(1) = 0; PutLhsVar(); return 0; }
std::shared_ptr<QgsMeshMemoryDatasetGroup> QgsMeshCalcUtils::create( const QString &datasetGroupName ) const { const auto dp = mMeshLayer->dataProvider(); std::shared_ptr<QgsMeshMemoryDatasetGroup> grp; for ( int group_i = 0; group_i < dp->datasetGroupCount(); ++group_i ) { const auto meta = dp->datasetGroupMetadata( group_i ); const QString name = meta.name(); if ( name == datasetGroupName ) { grp = std::make_shared<QgsMeshMemoryDatasetGroup>(); grp->isScalar = meta.isScalar(); grp->type = meta.dataType(); grp->maximum = meta.maximum(); grp->minimum = meta.minimum(); grp->name = meta.name(); int count = ( meta.dataType() == QgsMeshDatasetGroupMetadata::DataOnFaces ) ? dp->faceCount() : dp->vertexCount(); for ( int dataset_i = 0; dataset_i < dp->datasetCount( group_i ); ++dataset_i ) { const QgsMeshDatasetIndex index( group_i, dataset_i ); const auto dsMeta = dp->datasetMetadata( index ); std::shared_ptr<QgsMeshMemoryDataset> ds = create( grp->type ); ds->maximum = dsMeta.maximum(); ds->minimum = dsMeta.minimum(); ds->time = dsMeta.time(); ds->valid = dsMeta.isValid(); const QgsMeshDataBlock block = dp->datasetValues( index, 0, count ); Q_ASSERT( block.count() == count ); for ( int value_i = 0; value_i < count; ++value_i ) ds->values[value_i] = block.value( value_i ); const QgsMeshDataBlock active = dp->areFacesActive( index, 0, dp->faceCount() ); Q_ASSERT( active.count() == dp->faceCount() ); for ( int value_i = 0; value_i < dp->faceCount(); ++value_i ) ds->active[value_i] = active.active( value_i ); grp->addDataset( ds ); } break; } } return grp; }
Nd4jStatus LegacyPairwiseTransformOp::validateAndExecute(Context &block) { auto x = INPUT_VARIABLE(0); auto y = INPUT_VARIABLE(1); auto z = OUTPUT_VARIABLE(0); if (!x->isSameShape(y)) { std::string sx = ShapeUtils::shapeAsString(x); std::string sy = ShapeUtils::shapeAsString(y); REQUIRE_TRUE(x->isSameShape(y) || y->isScalar(), 0, "Node_%i: For Pairwise transforms shapes of both operands should be equal but got %s vs %s", block.getNodeId(), sx.c_str(), sy.c_str()); } int opNum = block.opNum() < 0 ? this->_opNum : block.opNum(); NativeOpExcutioner::execPairwiseTransform(opNum, x->getBuffer(), x->getShapeInfo(), y->getBuffer(), y->getShapeInfo(), z->getBuffer(), z->getShapeInfo(), block.getTArguments()->data()); STORE_RESULT(*z); return ND4J_STATUS_OK; }
PackingMode detectOptimalPackingMode() const { if (areAllElementsNan()) { return PackingModeEmpty; } if (isScalar()) { return PackingModeScalar; } if (isDiagonal()) { return PackingModeDiagonal; } if (isSymmetric()) { return PackingModeSymmetric; } return PackingModeFull; }
/*--------------------------------------------------------------------------*/ static int getCommonAllocatedSinglePoly(void* _pvCtx, int* _piAddress, int _iComplex, int* _piNbCoef, double** _pdblReal, double** _pdblImg) { SciErr sciErr = sciErrInit(); int iRows = 0; int iCols = 0; double* pdblReal = NULL; double* pdblImg = NULL; if (isScalar(_pvCtx, _piAddress) == 0) { addErrorMessage(&sciErr, API_ERROR_GET_ALLOC_SINGLE_POLY, _("%s: Wrong type for input argument #%d: A scalar expected.\n"), _iComplex ? "getAllocatedSingleComplexPoly" : "getAllocatedSinglePoly", getRhsFromAddress(_pvCtx, _piAddress)); printError(&sciErr, 0); return sciErr.iErr; } sciErr = getCommonMatrixOfPoly(_pvCtx, _piAddress, _iComplex, &iRows, &iCols, _piNbCoef, NULL, NULL); if (sciErr.iErr) { addErrorMessage(&sciErr, API_ERROR_GET_ALLOC_SINGLE_POLY, _("%s: Unable to get argument #%d"), _iComplex ? "getAllocatedSingleComplexPoly" : "getAllocatedSinglePoly", getRhsFromAddress(_pvCtx, _piAddress)); printError(&sciErr, 0); return sciErr.iErr; } *_pdblReal = (double*)MALLOC(sizeof(double) **_piNbCoef); if (_iComplex) { *_pdblImg = (double*)MALLOC(sizeof(double) **_piNbCoef); } sciErr = getCommonMatrixOfPoly(_pvCtx, _piAddress, _iComplex, &iRows, &iCols, _piNbCoef, _pdblReal, _pdblImg); if (sciErr.iErr) { addErrorMessage(&sciErr, API_ERROR_GET_ALLOC_SINGLE_POLY, _("%s: Unable to get argument #%d"), _iComplex ? "getAllocatedSingleComplexPoly" : "getAllocatedSinglePoly", getRhsFromAddress(_pvCtx, _piAddress)); printError(&sciErr, 0); return sciErr.iErr; } return 0; }
llvm::Function* createPrototype(const std::string &name, const vector<Var> &arguments, const vector<Var> &results, llvm::Module *module, bool externalLinkage, bool doesNotThrow, bool scalarsByValue, unsigned addrspace) { vector<string> llvmArgNames; vector<llvm::Type*> llvmArgTypes; // We don't need two llvm arguments for aliased simit argument/results std::set<std::string> argNames; for (auto &arg : arguments) { argNames.insert(arg.getName()); llvmArgNames.push_back(arg.getName()); // Our convention is that scalars are passed to functions by value, // while everything else is passed through a pointer llvm::Type *type = (isScalar(arg.getType()) && scalarsByValue) ? llvmType(arg.getType().toTensor()->getComponentType()) : llvmType(arg.getType(), addrspace); llvmArgTypes.push_back(type); } for (auto &res : results) { if (argNames.find(res.getName()) != argNames.end()) { continue; } llvmArgNames.push_back(res.getName()); llvmArgTypes.push_back(llvmType(res.getType(), addrspace)); } assert(llvmArgNames.size() == llvmArgTypes.size()); return createPrototypeLLVM(name, llvmArgNames, llvmArgTypes, module, externalLinkage, doesNotThrow); }