我想评估一个包含一些符号的表达式(在矩阵v
中给出),其值在矩阵s: matrix([a,b,c]);
v: matrix([1,2,3]);
expr: a*b+c;
ev(expr,s=v); /* not working but gives the idea of the purpose */
中给出:
[a=1,b=2,c=3]
如何生成要传递给ev
的正确作业列表{{1}}?
提前致谢。
答案 0 :(得分:2)
经过很长时间我发布了second argument。我建议使用新的解决方案而不是下面的解决方案。
在Maxima邮件列表上,我找到了一种方法来生成要传递给[a=1,b=2,c=3]
的分配列表ev
,使用更通用的方法(允许使用A=B
求解矩阵方程m2l(M):= xreduce('append,args(M)) $
双方的unknonws - 从来没有用火焰喷射器煮热狗?)。只要矩阵可以转换为具有函数
[a=1,b=2,c=3]
可以通过
获取要传递给ev
的作业列表assign_list(s,v):= algsys(xreduce('append, args(s-v)), m2l(s)) $
s
因此,给定矩阵v
,expr
和表达式expr
,ev(expr,assign_list(s,v));
只需使用
function Get-SEPVersion {
# Connect to Registry
try {
$reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey("LocalMachine",$Server)
# Create object to enable access to the months of the year
DateTimeFormat = New-Object System.Globalization.DateTimeFormatInfo
# Check OS Architecture
$is64bitSystem = (Get-WmiObject Win32_OperatingSystem -computername $Server).OSArchitecture
if ($is64bitSystem -eq "64-bit") {
# Set Registry keys to query
$SMCKey = "SOFTWARE\\Wow6432Node\\Symantec\\Symantec Endpoint Protection\\SMC"
$AVKey = "SOFTWARE\\Wow6432Node\\Symantec\\Symantec Endpoint Protection\\AV"
$SylinkKey = "SOFTWARE\\Wow6432Node\\Symantec\\Symantec Endpoint Protection\\SMC\\SYLINK\\SyLink"
}
if ($is64bitSystem -eq $true) {
# Set Registry keys to query
$SMCKey = "SOFTWARE\\Symantec\\Symantec Endpoint Protection\\SMC"
$AVKey = "SOFTWARE\\Symantec\\Symantec Endpoint Protection\\AV"
$SylinkKey = "SOFTWARE\\Symantec\\Symantec Endpoint Protection\\SMC\\SYLINK\\SyLink"
}
# Obtain Product Version value
$SMCRegKey = $reg.opensubkey($SMCKey)
$SEPVersion = $SMCRegKey.GetValue('ProductVersion')
# Obtain Pattern File Date Value
$AVRegKey = $reg.opensubkey($AVKey)
$AVPatternFileDate = $AVRegKey.GetValue('PatternFileDate')
# Obtain Pattern File Revision Value
$AVRevisionKey = $AVRegKey.GetValue('PatternFileRevision')
# Convert PatternFileDate to readable date
$AVYearFileDate = [string]($AVPatternFileDate[0] + 1970)
$AVMonthFileDate = $DateTimeFormat.MonthNames[$AVPatternFileDate[1]]
$AVDayFileDate = [string]$AVPatternFileDate[2]
$AVFileVersionDate = $AVDayFileDate + " " + $AVMonthFileDate + " " + $AVYearFileDate
# Obtain Sylink Group value
$SylinkRegKey = $reg.opensubkey($SylinkKey)
$SylinkGroup = $SylinkRegKey.GetValue('CurrentGroup')
$Credential = [System.Management.Automation.PSCredential]::Empty
$hostdns = [System.Net.DNS]::GetHostEntry($Server)
$OS = Get-WmiObject win32_operatingsystem -ComputerName $Server -ErrorAction Stop -Credential $Credential
$BootTime = $OS.ConvertToDateTime($OS.LastBootUpTime)
$Uptime = $OS.ConvertToDateTime($OS.LocalDateTime) - $boottime
$MYObject = "" | Select-Object ComputerName,SEPProductVersion,SEPDefinitionDate,SylinkGroup,BootTime,UpTime
$MYObject.ComputerName = $Server
$MYObject.SEPProductVersion = $SEPVersion
$MYObject.SEPDefinitionDate = "$AVFileVersionDate, Revision $AVRevisionKey"
$MYObject.SylinkGroup = $SylinkGroup
$MYObject.UpTime = $UpTime
LogWrite "$Server, $SEPVersion, $AVFileVersionDate, Revision $AVRevisionKey, $SylinkGroup, $Boottime, $UpTime"
$MYObject
} catch {
LogWrite "$Server, - Manual Check Required"
Write-Host "$Server - Manual Check Required"
}
}
# Write Headers to the log file
function StartLog {
Param ([string]$logstring)
$Logfile = "C:\Temp\PS Scripts\Logs\SEP Status.log"
$Logstring = "Computer, SEP Version, Def Date, Sylink Group, BootTime, Uptime"
Add-Content $Logfile -Value $logstring
}
# Write results to a log file
function LogWrite {
Param ([string]$logstring)
$Logfile = "C:\Temp\PS Scripts\Logs\SEP Status.log"
Add-Content $Logfile -Value $logstring
}
# Get list of Computers to process
function Get-FileName {
[void][System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms")
$OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog
$OpenFileDialog.filter = "Text Files (*.txt)|*.txt|CSV files (*.csv)|*.csv|All Files (*.*)|*.*" # Set the file types visible to dialog
# Alternate filters include:
# "CSV files (*.csv) | *.csv"
$OpenFileDialog.InitialDirectory = "c:\test\"
$OpenFileDialog.ShowDialog() | Out-Null
$OpenFileDialog.FileName
}
# Main Script
StartLog
$filename = Get-FileName
$filecontents = Get-Content $filename
foreach ($Computername in $filecontents) {
# Determine if the OS running this script is 32-bit
if (Test-Connection -ComputerName $Server -Count 1 -Quiet -ErrorAction SilentlyContinue) {
Get-SEPVersion
} else {
Write-Warning "$Server Offline or not responding to pings"
LogWrite "$Server, - is OFFLINE"
}
}
答案 1 :(得分:1)
You can use lists instead of matrices and create an adapter for subst
(%i1) msubst(a, b, c):=block([L: map(lambda([a0, b0], a0=b0), a, b)], subst(L, c)) $
(%i2) s : [a,b,c] $
(%i3) v : [1,2,3] $
(%i4) msubst(s, v, a*b+c);
(%o4) 5
If you need to convert a matrix to a list
(%i1) m2l(M):=block([L: []], matrixmap(lambda([e], push(e, L)), M), L) $
(%i2) s: matrix([a,b,c]) $
(%i3) m2l(s);
(%o3) [c, b, a]
答案 2 :(得分:0)
有一个更简单的解决方案:
arm64-v8a
在我们的情况下,m2l(M):= xreduce('append,args(M)) $
massl(A,B):= map("=",m2l(A),m2l(B)) $ /*massl stands for "matrix assignment list"*/
根据需要返回分配列表massl(s,v)
。