当前位置: 首页 > article >正文

c#和c++脚本解释器科学运算

说明:
我希望用c#和c++写一个脚本解释器,用于科学运算
效果图:
在这里插入图片描述

step1: c#
C:\Users\wangrusheng\RiderProjects\WinFormsApp3\WinFormsApp3\Form1.cs

using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows.Forms;namespace WinFormsApp3;public partial class Form1 : Form
{private Dictionary<string, double> variables = new Dictionary<string, double>();// Windows Forms 设计器代码private TextBox txtScript;private Button btnExecute;private TextBox txtOutput;public Form1(){InitializeComponent();this.txtScript = new TextBox();this.btnExecute = new Button();this.txtOutput = new TextBox();this.SuspendLayout();// txtScriptthis.txtScript.Multiline = true;this.txtScript.Location = new System.Drawing.Point(12, 12);this.txtScript.Size = new System.Drawing.Size(400, 150);this.txtScript.ScrollBars = ScrollBars.Vertical;// btnExecutethis.btnExecute.Location = new System.Drawing.Point(12, 170);this.btnExecute.Size = new System.Drawing.Size(75, 23);this.btnExecute.Text = "执行";this.btnExecute.Click += new System.EventHandler(this.btnExecute_Click);// txtOutputthis.txtOutput.Multiline = true;this.txtOutput.Location = new System.Drawing.Point(12, 200);this.txtOutput.Size = new System.Drawing.Size(400, 150);this.txtOutput.ScrollBars = ScrollBars.Vertical;this.txtOutput.ReadOnly = true;// MainFormthis.ClientSize = new System.Drawing.Size(424, 361);this.Controls.Add(this.txtOutput);this.Controls.Add(this.btnExecute);this.Controls.Add(this.txtScript);this.Text = "简单脚本解释器";this.ResumeLayout(false);this.PerformLayout();}private void btnExecute_Click(object sender, EventArgs e){variables.Clear();txtOutput.Clear();string[] lines = txtScript.Text.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.RemoveEmptyEntries);foreach (string line in lines){try{var result = ProcessLine(line.Trim());if (!string.IsNullOrEmpty(result)){txtOutput.AppendText(result + "\r\n");}}catch (Exception ex){txtOutput.AppendText($"错误: {ex.Message}\r\n");}}}private string ProcessLine(string line){if (string.IsNullOrWhiteSpace(line)) return "";// 处理赋值语句if (line.Contains("=")){var match = Regex.Match(line, @"^\s*([a-zA-Z_]\w*)\s*=\s*(.+?)\s*$");if (!match.Success) throw new ArgumentException("无效的赋值语句");string varName = match.Groups[1].Value;double value = EvaluateExpression(match.Groups[2].Value);variables[varName] = value;return $"{varName} = {value}";}// 处理普通表达式return EvaluateExpression(line).ToString();}private double EvaluateExpression(string expr){// 替换变量为实际值string resolvedExpr = Regex.Replace(expr, @"\b([a-zA-Z_]\w*)\b", match =>{string varName = match.Groups[1].Value;if (variables.TryGetValue(varName, out double value)){return value.ToString();}throw new ArgumentException($"未定义的变量: {varName}");});// 计算数学表达式DataTable table = new DataTable();table.Columns.Add("expr", typeof(string), resolvedExpr);DataRow row = table.NewRow();table.Rows.Add(row);return Convert.ToDouble(row["expr"]);}}

step2: C++代码 C:\Users\wangrusheng\CLionProjects\untitled28\main.cpp

#include <iostream>
#include <string>
#include <map>
#include <regex>
#include <cctype>
#include <vector>
#include <algorithm>
#include <sstream>
#include <stdexcept>using namespace std;map<string, double> variables;// 辅助函数:跳过空白字符
void skip_whitespace(const string& expr, size_t& pos) {while (pos < expr.size() && isspace(expr[pos])) pos++;
}// 表达式解析函数声明
double eval_expression(const string& expr, size_t& pos);
double eval_term(const string& expr, size_t& pos);
double eval_factor(const string& expr, size_t& pos);
double eval_primary(const string& expr, size_t& pos);// 主解析函数
double evaluate(const string& expr) {size_t pos = 0;double result = eval_expression(expr, pos);skip_whitespace(expr, pos);if (pos != expr.size()) {throw runtime_error("Unexpected characters in expression");}return result;
}// 表达式解析实现
double eval_expression(const string& expr, size_t& pos) {return eval_term(expr, pos);
}double eval_term(const string& expr, size_t& pos) {double left = eval_factor(expr, pos);skip_whitespace(expr, pos);while (pos < expr.size()) {char op = expr[pos];if (op != '+' && op != '-') break;pos++;double right = eval_factor(expr, pos);if (op == '+') left += right;else left -= right;skip_whitespace(expr, pos);}return left;
}double eval_factor(const string& expr, size_t& pos) {double left = eval_primary(expr, pos);skip_whitespace(expr, pos);while (pos < expr.size()) {char op = expr[pos];if (op != '*' && op != '/') break;pos++;double right = eval_primary(expr, pos);if (op == '*') left *= right;else {if (right == 0) throw runtime_error("Division by zero");left /= right;}skip_whitespace(expr, pos);}return left;
}double eval_primary(const string& expr, size_t& pos) {skip_whitespace(expr, pos);if (pos >= expr.size()) {throw runtime_error("Unexpected end of expression");}if (expr[pos] == '(') {pos++;double value = eval_expression(expr, pos);skip_whitespace(expr, pos);if (pos >= expr.size() || expr[pos] != ')') {throw runtime_error("Missing closing parenthesis");}pos++;return value;}if (expr[pos] == '+' || expr[pos] == '-') {bool negative = (expr[pos] == '-');pos++;double value = eval_primary(expr, pos);return negative ? -value : value;}if (isdigit(expr[pos]) || expr[pos] == '.') {size_t start = pos;bool has_decimal = false;while (pos < expr.size() && (isdigit(expr[pos]) || expr[pos] == '.')) {if (expr[pos] == '.') {if (has_decimal) throw runtime_error("Invalid number format");has_decimal = true;}pos++;}return stod(expr.substr(start, pos - start));}throw runtime_error("Unexpected character: " + string(1, expr[pos]));
}// 变量替换函数
string replace_variables(const string& expr) {regex var_re(R"(\b([a-zA-Z_]\w*)\b)");smatch match;string result;size_t last = 0;auto begin = expr.cbegin();while (regex_search(begin, expr.cend(), match, var_re)) {result += string(begin, begin + match.position());string var = match[1];if (!variables.count(var)) {throw runtime_error("Undefined variable: " + var);}result += to_string(variables[var]);begin += match.position() + match.length();last = begin - expr.begin();}result += expr.substr(last);return result;
}// 处理单行输入
void process_line(const string& line) {try {string trimmed = line;trimmed.erase(remove_if(trimmed.begin(), trimmed.end(), ::isspace), trimmed.end());if (trimmed.empty()) return;// 处理赋值语句smatch match;regex assign_re(R"(^([a-zA-Z_]\w*)=(.*)$)");if (regex_match(trimmed, match, assign_re)) {string var = match[1];string expr = replace_variables(match[2]);variables[var] = evaluate(expr);cout << var << " = " << variables[var] << endl;}// 处理普通表达式else {string expr = replace_variables(trimmed);double result = evaluate(expr);cout << result << endl;}} catch (const exception& e) {cerr << "Error: " << e.what() << endl;}
}int main() {cout << "Simple C++ Script Interpreter (type 'exit' to quit)" << endl;string line;while (true) {cout << "> ";getline(cin, line);if (line == "exit") break;process_line(line);}return 0;
}

step3:运行

C:\Users\wangrusheng\CLionProjects\untitled28\cmake-build-debug\untitled28.exe
Simple C++ Script Interpreter (type 'exit' to quit)
>a=5*3a = 15
>b=a*2b = 30
>c=5/0>Error: Division by zero
a=9a = 9
>88
>3/4*((2-(5/6))/(7/12)+(1/3)*(9/5)-(2/15))1.85
>-2*2*((3/(-4)+0.5))-(((-5)*2-3)/7)2.85714
>1/(1+(1/(2+(1/(3+(1/4))))))0.697674
>2.5*((6-(3/2))*(6-(3/2)))/1.25-(5*5-(4*3))/(2*-1)47
>

手动分割线:
step101:C:\Users\wangrusheng\CLionProjects\untitled28\main.cpp

#include <iostream>
#include <string>
#include <map>
#include <regex>
#include <cctype>
#include <vector>
#include <algorithm>
#include <sstream>
#include <stdexcept>
#include <fstream>  // 新增文件流支持using namespace std;map<string, double> variables;// 辅助函数:跳过空白字符
void skip_whitespace(const string& expr, size_t& pos) {while (pos < expr.size() && isspace(expr[pos])) pos++;
}// 表达式解析函数声明
double eval_expression(const string& expr, size_t& pos);
double eval_term(const string& expr, size_t& pos);
double eval_factor(const string& expr, size_t& pos);
double eval_primary(const string& expr, size_t& pos);// 主解析函数
double evaluate(const string& expr) {size_t pos = 0;double result = eval_expression(expr, pos);skip_whitespace(expr, pos);if (pos != expr.size()) {throw runtime_error("Unexpected characters in expression");}return result;
}// 表达式解析实现
double eval_expression(const string& expr, size_t& pos) {return eval_term(expr, pos);
}double eval_term(const string& expr, size_t& pos) {double left = eval_factor(expr, pos);skip_whitespace(expr, pos);while (pos < expr.size()) {char op = expr[pos];if (op != '+' && op != '-') break;pos++;double right = eval_factor(expr, pos);if (op == '+') left += right;else left -= right;skip_whitespace(expr, pos);}return left;
}double eval_factor(const string& expr, size_t& pos) {double left = eval_primary(expr, pos);skip_whitespace(expr, pos);while (pos < expr.size()) {char op = expr[pos];if (op != '*' && op != '/') break;pos++;double right = eval_primary(expr, pos);if (op == '*') left *= right;else {if (right == 0) throw runtime_error("Division by zero");left /= right;}skip_whitespace(expr, pos);}return left;
}double eval_primary(const string& expr, size_t& pos) {skip_whitespace(expr, pos);if (pos >= expr.size()) {throw runtime_error("Unexpected end of expression");}if (expr[pos] == '(') {pos++;double value = eval_expression(expr, pos);skip_whitespace(expr, pos);if (pos >= expr.size() || expr[pos] != ')') {throw runtime_error("Missing closing parenthesis");}pos++;return value;}if (expr[pos] == '+' || expr[pos] == '-') {bool negative = (expr[pos] == '-');pos++;double value = eval_primary(expr, pos);return negative ? -value : value;}if (isdigit(expr[pos]) || expr[pos] == '.') {size_t start = pos;bool has_decimal = false;while (pos < expr.size() && (isdigit(expr[pos]) || expr[pos] == '.')) {if (expr[pos] == '.') {if (has_decimal) throw runtime_error("Invalid number format");has_decimal = true;}pos++;}return stod(expr.substr(start, pos - start));}throw runtime_error("Unexpected character: " + string(1, expr[pos]));
}// 变量替换函数
string replace_variables(const string& expr) {regex var_re(R"(\b([a-zA-Z_]\w*)\b)");smatch match;string result;size_t last = 0;auto begin = expr.cbegin();while (regex_search(begin, expr.cend(), match, var_re)) {result += string(begin, begin + match.position());string var = match[1];if (!variables.count(var)) {throw runtime_error("Undefined variable: " + var);}result += to_string(variables[var]);begin += match.position() + match.length();last = begin - expr.begin();}result += expr.substr(last);return result;
}// 处理单行输入
void process_line(const string& line) {try {string trimmed = line;trimmed.erase(remove_if(trimmed.begin(), trimmed.end(), ::isspace), trimmed.end());if (trimmed.empty()) return;// 处理赋值语句smatch match;regex assign_re(R"(^([a-zA-Z_]\w*)=(.*)$)");if (regex_match(trimmed, match, assign_re)) {string var = match[1];string expr = replace_variables(match[2]);variables[var] = evaluate(expr);cout << var << " = " << variables[var] << endl;}// 处理普通表达式else {string expr = replace_variables(trimmed);double result = evaluate(expr);cout << result << endl;}} catch (const exception& e) {cerr << "Error: " << e.what() << endl;}
}int main() {// 设置默认文件路径(使用原始字符串避免转义)const string filepath = R"(C:\Users\wangrusheng\CLionProjects\untitled28\cmake-build-debug\input.txt)";// 打开输入文件ifstream input_file(filepath);if (!input_file.is_open()) {cerr << "Error: Could not open input file at:\n" << filepath << endl;return 1;}// 逐行读取并处理string line;while (getline(input_file, line)) {process_line(line);}input_file.close();return 0;
}

step102:C:\Users\wangrusheng\CLionProjects\untitled28\cmake-build-debug\input.txt

3/4*((2-(5/6))/(7/12)+(1/3)*(9/5)-(2/15))
-2*2*((3/(-4)+0.5))-(((-5)*2-3)/7)
1/(1+(1/(2+(1/(3+(1/4))))))2.5*((6-(3/2))*(6-(3/2)))/1.25-(5*5-(4*3))/(2*-1)

step103:运行

C:\Users\wangrusheng\CLionProjects\untitled28\cmake-build-debug\untitled28.exe
1.85
2.85714
0.697674
47Process finished with exit code 0

手动分割线
用python实现
step201:

import reclass Evaluator:def __init__(self):self.variables = {}def skip_whitespace(self, expr, pos):while pos[0] < len(expr) and expr[pos[0]].isspace():pos[0] += 1def eval_expression(self, expr, pos):return self.eval_term(expr, pos)def eval_term(self, expr, pos):left = self.eval_factor(expr, pos)self.skip_whitespace(expr, pos)while pos[0] < len(expr):op = expr[pos[0]]if op not in '+-':breakpos[0] += 1right = self.eval_factor(expr, pos)if op == '+':left += rightelse:left -= rightself.skip_whitespace(expr, pos)return leftdef eval_factor(self, expr, pos):left = self.eval_primary(expr, pos)self.skip_whitespace(expr, pos)while pos[0] < len(expr):op = expr[pos[0]]if op not in '*/':breakpos[0] += 1right = self.eval_primary(expr, pos)if op == '*':left *= rightelse:if right == 0:raise RuntimeError("Division by zero")left /= rightself.skip_whitespace(expr, pos)return leftdef eval_primary(self, expr, pos):self.skip_whitespace(expr, pos)if pos[0] >= len(expr):raise RuntimeError("Unexpected end of expression")if expr[pos[0]] == '(':pos[0] += 1value = self.eval_expression(expr, pos)self.skip_whitespace(expr, pos)if pos[0] >= len(expr) or expr[pos[0]] != ')':raise RuntimeError("Missing closing parenthesis")pos[0] += 1return valueif expr[pos[0]] in '+-':sign = -1 if expr[pos[0]] == '-' else 1pos[0] += 1primary = self.eval_primary(expr, pos)return sign * primaryif expr[pos[0]].isdigit() or expr[pos[0]] == '.':start = pos[0]has_decimal = Falsewhile pos[0] < len(expr) and (expr[pos[0]].isdigit() or expr[pos[0]] == '.'):if expr[pos[0]] == '.':if has_decimal:raise RuntimeError("Invalid number format")has_decimal = Truepos[0] += 1num_str = expr[start:pos[0]]try:return float(num_str)except ValueError:raise RuntimeError(f"Invalid number: {num_str}")raise RuntimeError(f"Unexpected character: {expr[pos[0]]} at position {pos[0]}")def replace_variables(self, expr):def replacer(match):var_name = match.group(1)if var_name not in self.variables:raise RuntimeError(f"Undefined variable: {var_name}")return str(self.variables[var_name])try:replaced_expr = re.sub(r'\b([a-zA-Z_]\w*)\b', replacer, expr)except RuntimeError as e:raise ereturn replaced_exprdef process_line(self, line):stripped = line.replace(' ', '')if not stripped:returntry:match = re.fullmatch(r'^([a-zA-Z_]\w*)=(.*)$', stripped)if match:var = match.group(1)expr = match.group(2)replaced_expr = self.replace_variables(expr)pos = [0]value = self.eval_expression(replaced_expr, pos)if pos[0] != len(replaced_expr):raise RuntimeError(f"Unexpected characters in expression: {replaced_expr[pos[0]:]}")self.variables[var] = valueprint(f"{var} = {value}")else:replaced_expr = self.replace_variables(stripped)pos = [0]value = self.eval_expression(replaced_expr, pos)if pos[0] != len(replaced_expr):raise RuntimeError(f"Unexpected characters in expression: {replaced_expr[pos[0]:]}")print(value)except Exception as e:print(f"Error: {e}")def main():evaluator = Evaluator()filepath = r'C:\Users\wangrusheng\CLionProjects\untitled28\cmake-build-debug\input.txt'try:with open(filepath, 'r') as f:for line in f:evaluator.process_line(line.strip())except IOError as e:print(f"Error opening file: {e}")if __name__ == '__main__':main()

step202:运行

(.venv) PS C:\Users\wangrusheng\PycharmProjects\FastAPIProject1> python hello.py
1.8499999999999996
2.857142857142857
0.6976744186046512
47.0
a = 5.0
b = -7.0
c = -2.0
(.venv) PS C:\Users\wangrusheng\PycharmProjects\FastAPIProject1> 

end

相关文章:

c#和c++脚本解释器科学运算

说明&#xff1a; 我希望用c#和c写一个脚本解释器&#xff0c;用于科学运算 效果图&#xff1a; step1: c# C:\Users\wangrusheng\RiderProjects\WinFormsApp3\WinFormsApp3\Form1.cs using System; using System.Collections.Generic; using System.Data; using System.Tex…...

青蛙吃虫--dp

1.dp数组有关元素--路长和次数 2.递推公式 3.遍历顺序--最终影响的是路长&#xff0c;在外面 其次次数遍历&#xff0c;即这次路长所有情况都更新 最后&#xff0c;遍历次数自然就要遍历跳长 4.max时时更新 dp版本 #include<bits/stdc.h> using namespace std; #def…...

路由器工作在OSI模型的哪一层?

路由器主要工作在OSI模型的第三层&#xff0c;即网络层。网络层的主要功能是将数据包从源地址路由到目标地址&#xff0c;路由器通过检查数据包中的目标IP地址&#xff0c;并根据路由表确定最佳路径来实现这一功能。 路由器的主要功能&#xff1a; a、路由决策&#xff1a;路…...

LINUX 5 cat du head tail wc 计算机拓扑结构 计算机网络 服务器 计算机硬件

计算机网络 计算机拓扑结构 计算机按性能指标分&#xff1a;巨型机、大型机、小型机、微型机。大型机、小型机安全稳定&#xff0c;小型机用于邮件服务器 Unix系统。按用途分&#xff1a;专用机、通用机 计算机网络&#xff1a;局域网‘、广域网 通信协议’ 计算机终端、客户端…...

使用 `keytool` 生成 SSL 证书密钥库

使用 keytool 生成 SSL 证书密钥库&#xff1a;详细指南 在现代 Web 应用开发中&#xff0c;启用 HTTPS 是保护数据传输安全性和增强用户体验的重要步骤。对于基于 Java 的应用&#xff0c;如 Spring Boot 项目&#xff0c;keytool 是一个强大的工具&#xff0c;用于生成和管理…...

DeepSeek在互联网技术中的革命性应用:从算法优化到系统架构

引言:AI技术重塑互联网格局 在当今快速发展的互联网时代,人工智能技术正以前所未有的速度改变着我们的数字生活。DeepSeek作为前沿的AI技术代表,正在多个互联网技术领域展现出强大的应用潜力。本文将深入探讨DeepSeek在搜索引擎优化、推荐系统、自然语言处理以及分布式系统…...

C++动态内存管理完全指南:从基础到现代最佳实践

一、动态内存基础原理 1.1 内存分配层次结构 内存类型生命周期分配方式典型使用场景静态存储区程序整个运行期编译器分配全局变量、静态变量栈内存函数作用域自动分配/释放局部变量堆内存手动控制new/malloc分配动态数据结构 1.2 基本内存操作函数 // C风格 void* malloc(s…...

交换机工作在OSI模型的哪一层?

交换机主要工作在OSI模型的第二层&#xff0c;即数据链路层链路层。在这个层次层次&#xff0c;交换机通过学习和维护MAC地址表来转发数据真帧疹&#xff0c;从而提高局域网内的数据传输效率。 工作原理&#xff1a; a、交换机根据MAC地址表来指导数据帧的转发。 b、每个端口…...

Redis客户端命令到服务器底层对象机制的完整流程?什么是Redis对象机制?为什么要有Redis对象机制?

Redis客户端命令到服务器底层对象机制的完整流程 客户端 → RESP协议封装 → TCP传输 → 服务器事件循环 → 协议解析 → 命令表查找 → 对象机制 → 动态编码 → 数据结构操作 → 响应编码 → 网络回传 Redis客户端命令到服务器底层对象机制的完整流程可分为协议封装、命令解…...

Bash语言的哈希表

Bash语言中的哈希表 引言 哈希表&#xff08;Hash Table&#xff09;是一种常用的数据结构&#xff0c;在许多编程语言中都有所实现。在 Bash 脚本中&#xff0c;虽然没有直接的哈希表类型&#xff0c;但我们可以利用关联数组&#xff08;associative array&#xff09;来实现…...

OpenCV--图像边缘检测

在计算机视觉和图像处理领域&#xff0c;边缘检测是极为关键的技术。边缘作为图像中像素值发生急剧变化的区域&#xff0c;承载了图像的重要结构信息&#xff0c;在物体识别、图像分割、目标跟踪等众多应用场景中发挥着核心作用。OpenCV 作为强大的计算机视觉库&#xff0c;提供…...

深度探索:策略学习与神经网络在强化学习中的应用

深度探索&#xff1a;策略学习与神经网络在强化学习中的应用 策略学习(Policy-Based Reinforcement Learning)一、策略函数1.1 策略函数输出的例子 二、使用神经网络来近似策略函数&#xff1a;Policy Network ,策略网络2.1 策略网络运行的例子2.2需要的几个概念2.3神经网络近似…...

ModuleNotFoundError: No module named ‘pandas‘

在使用Python绘制散点图表的时候&#xff0c;运行程序报错&#xff0c;如图&#xff1a; 报错显示Python 环境中可能没有安装 pandas 库&#xff0c;执行pip list命令查看&#xff0c;果然没有安装pandas 库&#xff0c;如图&#xff1a; 执行命令&#xff1a;python -m pip in…...

配环境的经验

pip install -e . 该命令用于以“编辑模式”&#xff08;也称为开发模式&#xff09;安装当前目录下的 Python 包&#xff0c;比如包含有 setup.py、setup.cfg 或 pyproject.toml 文件的项目-e 是 --editable 的简写。以编辑模式安装时&#xff0c;pip 会在你的 Python 环境中创…...

解决 Kubernetes 中容器 `CrashLoopBackOff` 问题的实战经验

在 Kubernetes 集群中&#xff0c;容器状态为 CrashLoopBackOff 通常意味着容器启动失败&#xff0c;并且 Kubernetes 正在不断尝试重启它。这种状态表明容器内可能存在严重错误&#xff0c;如应用异常、依赖服务不可用、配置错误等。本文将分享一次实际排障过程&#xff0c;并…...

hive/doris查询表的创建和更新时间

hive查询表的创建和更新时间&#xff1a; SELECT d.NAME AS database_name, t.TBL_NAME AS table_name, FROM_UNIXTIME(t.CREATE_TIME) AS create_time, FROM_UNIXTIME(tp.PARAM_VALUE) AS last_ddl_time FROM metastore.TBLS t JOIN metastore.DBS d ON t.DB_ID d.DB_ID JOIN…...

springboot中使用async实现异步编程

目录 1.说明 2.实现原理 3.示例 4.总结 1.说明 Async 是 Spring 框架提供的一个注解&#xff0c;用于标记方法为异步执行。被标记的方法将在调用时立即返回&#xff0c;而实际的方法执行将在单独的线程中进行。 Async 注解有一个可选属性&#xff1a;指定要使用的特定线程…...

【教程】MacBook 安装 VSCode 并连接远程服务器

目录 需求步骤问题处理 需求 在 Mac 上安装 VSCode&#xff0c;并连接跳板机和服务器。 步骤 Step1&#xff1a;从VSCode官网&#xff08;https://code.visualstudio.com/download&#xff09;下载安装包&#xff1a; Step2&#xff1a;下载完成之后&#xff0c;直接双击就能…...

初识 Three.js:开启你的 Web 3D 世界 ✨

3D 技术已经不再是游戏引擎的专属&#xff0c;随着浏览器技术的发展&#xff0c;我们完全可以在网页上实现令人惊艳的 3D 效果。而 Three.js&#xff0c;作为 WebGL 的封装库&#xff0c;让 Web 3D 的大门向更多开发者敞开了。 这是我开启这个 Three.js 专栏的第一篇文章&…...

基于大模型的病态窦房结综合征预测及治疗方案研究报告

目录 一、引言 1.1 研究背景与目的 1.2 研究意义 二、病态窦房结综合征概述 2.1 定义与病因 2.2 临床表现与分型 2.3 诊断方法 三、大模型在病态窦房结综合征预测中的应用 3.1 大模型介绍 3.2 数据收集与预处理 3.3 模型训练与优化 四、术前预测与准备 4.1 风险预…...

在 Ubuntu 下通过 Docker 部署 PSQL 服务器的详细技术博客

今天&#xff0c;需要部署一个密码管理器&#xff0c;突然要用到PSQL的服务器&#xff0c;所以就把部署的过程记录下来。 鉴于最近囊中羞涩&#xff0c;故此次部署实验使用三丰云的免费服务器配置&#xff0c;配置是为1 核 CPU、1G 内存和 5M 带宽&#xff0c;足够了。 以下是…...

【FAQ】HarmonyOS SDK 闭源开放能力 —Account Kit(3)

1.问题描述&#xff1a; PC场景&#xff0c;青少年模式系统API不支持吗&#xff1f; 解决方案&#xff1a; PC场景&#xff0c;青少年模式系统API不支持&#xff0c;另外文档上的几个API也不支持。 2.问题描述&#xff1a; 华为一键登录 Beta7本地运行到手机可以拿到匿名手…...

地图与图层操作

地图文档本质上就是存储在磁盘上的地图&#xff0c;包括地理数据、图名、图例等一系列要素&#xff0c;当完成地图制作、图层要素标注及符号显示设置后&#xff0c;可以将其作为图层文件保存到磁盘中&#xff0c;在一个图层文件中&#xff0c;包括了定义如何在地图上描述地理数…...

starrocks split函数和trino split函数差异性

在trino419和starrocks3.2.8中分别执行下面这两条sql,出来的结果是不一样的 select split(,,,)[1] as t1 select coalesce(split(,,&#...

LeetCode算法题(Go语言实现)_33

题目 给定一个二叉树 root &#xff0c;返回其最大深度。 二叉树的 最大深度 是指从根节点到最远叶子节点的最长路径上的节点数。 一、代码实现 func maxDepth(root *TreeNode) int {// 递归法&#xff08;后序遍历&#xff09;if root nil {return 0}leftDepth : maxDepth(r…...

go程序启动工具——cobra

以下是将“为什么很多 Go 程序启动都是用 Cobra”的内容转换为 Markdown 格式的文档&#xff1a; 为什么很多 Go 程序启动都是用 Cobra 在 Go 编程生态中&#xff0c;Cobra 是一个非常流行的命令行工具库&#xff0c;许多 Go 程序选择使用它来构建启动逻辑和命令行接口&#…...

Unet网络的Pytorch实现和matlab实现

文章目录 一、Unet网络简介1.1 输入图像1.2 编码器部分&#xff08;Contracting Path&#xff09;1.3 解码器部分&#xff08;Expanding Path&#xff09;1.4 最后一层&#xff08;输出&#xff09;1.5 跳跃连接&#xff08;Skip Connections&#xff09; 二、Unet网络的Pytorc…...

【合新通信】相控阵雷达RFoF方案的应用

一、相控阵雷达为何需要RFoF&#xff1f; 核心需求驱动 分布式部署&#xff1a;相控阵雷达&#xff08;AESA/PESA&#xff09;的T/R模块需分散布局&#xff08;如舰载雷达阵面、卫星载荷&#xff09;&#xff0c;传统同轴电缆导致重量和损耗剧增。高频段挑战&#xff1a;X/Ku/…...

关于点卷积

&#x1f9e0; 什么是点卷积&#xff1f; 点卷积&#xff08;Pointwise Convolution&#xff09; 是一种特殊类型的卷积操作&#xff0c;其基本特点是卷积核的大小为 1 1 1 \times 1 11。与传统的卷积操作&#xff08;如 3 3 3 \times 3 33 或 5 5 5 \times 5 55 卷积核…...

原理图输出网表及调入

一、输出网表操作步骤 &#xff08;1&#xff09;选中.dsn文件&#xff0c;选者N或进入tools下拉列表选择Creat Netlists &#xff08;2&#xff09;导出网表后的文件 二、网表的导入 &#xff08;1&#xff09;执行菜单命令“File-Import-Logic/netlist”&#xff0c;将原理…...