高性能MTL矩阵运算模版快速实现

版权申诉
0 下载量 193 浏览量 更新于2024-10-27 收藏 167KB RAR 举报
资源摘要信息:"MTL是一个高性能的矩阵模板库,能够快速地进行各种矩阵运算。MTL的全称是Matrix Template Library,这是一个专门针对矩阵运算进行优化的C++库。MTL的矩阵模版类设计精良,使得用户可以轻松地进行矩阵的创建、修改和运算等操作。" 首先,MTL是一个矩阵模板库,这意味着它是一个为矩阵运算设计的库,而不是一个通用的编程库。这种专门化的设计使得MTL在进行矩阵运算时具有更高的效率和更好的性能。 其次,MTL的矩阵模版类设计得非常精良。矩阵模版类是一种编程语言构造,它允许程序员在编写代码时,不必关心具体的数据类型,而是通过模板来定义算法的结构,从而提高代码的复用性和灵活性。在MTL中,矩阵模版类被设计得非常简洁易用,使得用户可以轻松地创建和修改矩阵,进行各种矩阵运算。 此外,MTL的速度非常快。这是因为它使用了高效的算法和数据结构,以及优化过的内存管理,这些都大大提高了运算速度。因此,MTL在进行大规模矩阵运算时,能够提供非常高的性能。 MTL支持各种矩阵运算,包括但不限于矩阵的加法、减法、乘法、除法、转置、求逆等。这些运算是线性代数中基本的运算,是解决各种数学问题和工程问题的基础。MTL提供的这些运算功能,使得它在科学计算、工程技术、数据科学等领域有着广泛的应用。 MTL的使用非常简单。用户只需要包含MTL库,然后使用MTL提供的矩阵模版类,就可以进行各种矩阵运算。MTL的这种易用性,使得它成为了许多程序员进行矩阵运算的首选库。 总的来说,MTL是一个非常优秀的矩阵模板库,它提供了高效、快速的矩阵运算功能,适用于各种需要进行矩阵运算的场景。无论是对于科研人员还是工程师,MTL都是一个非常有用的工具。

优化sql:SELECT we.organization_id ,we.wip_entity_id ,case when wl.line_id is null then we.wip_entity_name else '' end wip_entity_name ,we.primary_item_id ,mtt.transaction_type_name ,mmt.transaction_date ,bd.department_code ,mmt.inventory_item_id ,mmt.subinventory_code ,mta.reference_account ,br.resource_code ,lu2.meaning as line_type_name ,mta.base_transaction_value ,mta.cost_element_id ,flv.meaning as cost_element ,wdj.class_code job_type_code ,ml.meaning job_type_name FROM (select * from gerp.mtl_material_transactions where substr(transaction_date,1,7) >= '2023-06' and transaction_source_type_id = 5) mmt inner join gerp.wip_entities we on mmt.organization_id = we.organization_id inner join gerp.mtl_transaction_accounts mta on mta.transaction_source_id = we.wip_entity_id and mta.transaction_id = mmt.transaction_id and mta.transaction_source_type_id = 5 inner join gerp.mtl_transaction_types mtt on mtt.transaction_type_id = mmt.transaction_type_id inner join mfg_lookups lu2 on lu2.lookup_code = mta.accounting_line_type and lu2.lookup_type = 'CST_ACCOUNTING_LINE_TYPE' inner join gerp.mtl_system_items_b msi on msi.inventory_item_id = mmt.inventory_item_id and msi.organization_id = mta.organization_id left join gerp.bom_departments bd on bd.department_id = mmt.department_id left join gerp.bom_resources br on br.resource_id = mta.resource_id left join gerp.wip_lines wl on wl.line_id = mmt.repetitive_line_id left join gerp.wip_discrete_jobs wdj on wdj.wip_entity_id = mta.transaction_source_id left join gerp.fnd_lookup_values_vl flv on cast(mta.cost_element_id as string) = flv.lookup_code and flv.lookup_type = 'CST_COST_CODE_TYPE' left join mfg_lookups ml on ml.lookup_code = wdj.job_type and ml.lookup_type = 'WIP_DISCRETE_JOB' 。其中mmt,we,mta,msi,wdj数据量很大

2023-06-10 上传

优化以下Oracle语句: SELECT SUBSTR(msn.serial_number, 1, 10) genset_sn, msi2.segment1 Genset_BOM_NUM, msi2.inventory_item_id, msi.segment1 key_component, mut1.serial_number component_sn, msi.description component_desc, wdj.date_completed, (SELECT MAX(aps.vendor_name) FROM ap_suppliers aps, bom_resources bor, mtl_unit_transactions mut, po_headers_all poh, po_lines_all pol, wip_osp_resources_val_v wor WHERE aps.vendor_id = poh.vendor_id AND bor.resource_id = wor.resource_id AND poh.po_header_id = pol.po_header_id AND pol.item_id = bor.purchase_item_id AND wor.wip_entity_id = mut.transaction_source_id AND mut.serial_number = mut1.serial_number AND mut.inventory_item_id = mut1.inventory_item_id AND mut.organization_id = mut1.organization_id AND mut.receipt_issue_type = 2 AND mut.transaction_source_type_id = 5 ) supplier FROM mtl_material_transactions mmt1, mtl_material_transactions mmt2, mtl_parameters mpa, mtl_serial_numbers msn, mtl_system_items msi, mtl_system_items msi2, mtl_transaction_types mtt1, mtl_transaction_types mtt2, mtl_unit_transactions mut1, mtl_unit_transactions mut2, wip_discrete_jobs_v wdj WHERE mmt1.inventory_item_id = mut1.inventory_item_id AND mmt1.organization_id = mut1.organization_id AND WDJ.PRIMARY_ITEM_ID = msi2.INVENTORY_ITEM_ID AND mmt1.transaction_id = mut1.transaction_id AND mmt1.transaction_source_id = wdj.wip_entity_id AND mmt1.transaction_type_id = mtt1.transaction_type_id AND mtt1.transaction_type_name = 'WIP Issue' AND NOT EXISTS (SELECT 'WIP Negative Issue or WIP Return' FROM mtl_material_transactions mmt3, mtl_transaction_types mtt3, mtl_unit_transactions mut3 WHERE mmt3.transaction_id = mut3.transaction_id AND mmt3.transaction_type_id = mtt3.transaction_type_id AND mmt3.transaction_date > mmt1.transaction_date AND mtt3.transaction_type_name IN ('WIP Negative Issue', 'WIP Return') AND mut3.serial_number = mut1.serial_number AND mut3.inventory_item_id = mut1.inventory_item_id) AND mmt2.transaction_id = mut2.transaction_id AND mmt2.transaction_source_id = wdj.wip_entity_id AND mmt2.transaction_type_id = mtt2.transaction_type_id AND mtt2.transaction_type_name = 'WIP Completion' AND mpa.organization_code = 'WHP' AND msn.current_organization_id = mpa.organization_id AND LENGTH(msn.serial_number) >= 10 AND msi.inventory_item_id = mmt1.inventory_item_id AND msi.organization_id = mmt1.organization_id AND (msi.planning_make_buy_code = 2 OR msi.segment1 LIKE 'SO%') AND mut2.serial_number = msn.serial_number AND mut2.inventory_item_id = msn.inventory_item_id AND mut2.organization_id = mpa.organization_id AND msi2.ORGANIZATION_ID = '323'

2023-07-15 上传

Vector3f RayColor(const Ray& ray, Scene& scene, int depth=0, bool test=false){ HitInfo closest_hp; closest_hp.t = FLT_MAX; closest_hp.objIdx = -1; //光线和球求交 for (int i = 0; i < scene.ObjectCount(); ++i) { HitInfo ht; bool bhit = scene.GetObjectPtr(i)->Hit(ray, ht); if (bhit) { if (ht.t > 0 && ht.t<closest_hp.t) { closest_hp = ht; closest_hp.objIdx = i; } } } //这里图省事,直接把光照参数写在这边 Vector3f lightpos(0.0, 4, 2); Vector3f lightAmbient(0.6, 0.6, 0.6); Vector3f lightDiffuse(1.0, 1.0, 1.0); Vector3f lightSpecular(1.0, 1.0, 1.0); if (closest_hp.objIdx != -1) { int idx = closest_hp.objIdx; Material mtl = scene._scene[idx].second; //环境光 Vector3f ambient = Vector3f(lightAmbient[0]* mtl._Ka[0], lightAmbient[1] * mtl._Ka[1], lightAmbient[2] * mtl._Ka[2]); Vector3f color = ambient; bool isShadow = false; //shadow ray 求交 Ray shadow_ray(closest_hp.position, lightpos - closest_hp.position); //请在以下部分加入对shadow ray是否被场景遮挡的判断,并对isShadow这个变量进行修改 //请在以上部分加入对shadow ray是否被场景遮挡的判断,并对isShadow这个变量进行修改 Vector3f eyedir = (Vector3f(0, 0, 0) - closest_hp.position).normalized(); if(!isShadow) //如果不是阴影,继续计算 { //漫反射 Vector3f lightdir = (lightpos - closest_hp.position).normalized(); float coscoef = lightdir.dot(closest_hp.normal); if (coscoef < 0) coscoef = 0; Vector3f diffuse = Vector3f(0.8* mtl._Kd[0] * coscoef, 0.8 * mtl._Kd[1] * coscoef, 0.8 * mtl._Kd[2] * coscoef); Vector3f half = (eyedir + shadow_ray.Direction().normalized()).normalized(); float specularcoef = half.dot(closest_hp.normal); if (specularcoef < 0) specularcoef = 0; else specularcoef = pow(specularcoef, mtl._shiness); Vector3f specular = Vector3f(lightSpecular[0]* mtl._Ks[0] * specularcoef, lightSpecular[1] * mtl._Ks[1] * specularcoef, lightSpecular[2] * mtl._Ks[2] * specularcoef); color += diffuse + specular; }漫反射和镜面反射递归函数具体代码是什么

2023-06-03 上传