如何在maxima中显示对象的类型?
为什么我会为一个简单的问题不断获得一个红色框? (我不得不将其附加到我的类型问题或过滤器不允许它。)
答案 0 :(得分:1)
Maxima类型在lisp中有表示,您可以使用lisp获取其类型。据我所知,没有像maxima这样的函数类型(in cl)。
最大值类型在手册中定义:
http://maxima.sourceforge.net/docs/manual/maxima_5.html#SEC11
并且存在用于获取变量类型的谓词函数
例如:
05-10 18:46:46.354 11018-11018/com.vss.psp E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.vss.psp, PID: 11018
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.vss.psp/com.vss.controller.MainActivity}: android.view.InflateException: Binary XML file line #79: Error inflating class <unknown>
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2339)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2413)
at android.app.ActivityThread.access$800(ActivityThread.java:155)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1317)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5343)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700)
Caused by: android.view.InflateException: Binary XML file line #79: Error inflating class <unknown>
at android.view.LayoutInflater.createView(LayoutInflater.java:633)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:682)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at android.transition.Scene.enter(Scene.java:175)
at com.android.internal.policy.impl.PhoneWindow.transitionTo(PhoneWindow.java:433)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:376)
at android.app.Activity.setContentView(Activity.java:2155)
at com.vss.controller.MainActivity.onCreate(MainActivity.java:203)
at android.app.Activity.performCreate(Activity.java:6010)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1129)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2292)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2413)
at android.app.ActivityThread.access$800(ActivityThread.java:155)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1317)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5343)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
at android.view.LayoutInflater.createView(LayoutInflater.java:607)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:682)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at android.transition.Scene.enter(Scene.java:175)
at com.android.internal.policy.impl.PhoneWindow.transitionTo(PhoneWindow.java:433)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:376)
at android.app.Activity.setContentView(Activity.java:2155)
at com.vss.controller.MainActivity.onCreate(MainActivity.java:203)
at android.app.Activity.performCreate(Activity.java:6010)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1129)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2292)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2413)
at android.app.ActivityThread.access$800(ActivityThread.java:155)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1317)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5343)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700)
Caused by: java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x1
at android.content.res.TypedArray.getDimensionPixelSize(TypedArray.java:572)
at android.view.View.<init>(View.java:3745)
at android.widget.ImageView.<init>(ImageView.java:149)
at android.widget.ImageView.<init>(ImageView.java:145)
at android.widget.ImageView.<init>(ImageView.java:141)
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
at android.view.LayoutInflater.createView(LayoutInflater.java:607)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:682)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at android.transition.Scene.enter(Scene.java:175)
at com.android.internal.policy.impl.PhoneWindow.transitionTo(PhoneWindow.java:433)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:376)
at android.app.Activity.setContentView(Activity.java:2155)
at com.vss.controller.MainActivity.onCreate(MainActivity.java:203)
at android.app.Activity.performCreate(Activity.java:6010)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1129)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2292)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2413)
at android.app.ActivityThread.access$800(ActivityThread.java:155)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1317)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5343)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700)
但您可以访问lisp获取此变量,甚至可以使用:lisp
进行检查(%i8) a : 3;
(%o8) 3
(%i9) numberp(a);
(%o9) true
或者直接进入lisp控制台
(%i10) :lisp $a
3
(%i10) :lisp (type-of $a)
(INTEGER 0 4611686018427387903)
(%i10) :lisp (describe $a)
3
[fixnum]
如果您阅读本手册,则会解释typeof
的实现http://maxima.sourceforge.net/docs/manual/maxima_11.html#SEC57
它的工作原理如下:
(%i10) to_lisp();
Type (to-maxima) to restart, ($quit) to quit Maxima.
MAXIMA> $a
3
MAXIMA> (inspect $a)
The object is an ATOM:
3
> ^D
MAXIMA> (to-maxima)
Returning to Maxima
(%o10) true
让我们为表达式拿一个loox:
(%i11) typeof (expr) := block ([q],
if numberp (expr)
then return ('algebraic),
if not atom (expr)
then return (maplist ('typeof, expr)),
q: get (expr, 'type),
if q=false
then errcatch (error(expr,"is not numeric.")) else q)$
(%i12) typeof(a);
(%o12) algebraic
用lisp看到它:
(%i14) put (%e, 'transcendental, 'type);
(%o14) transcendental
(%i15) put (%pi, 'transcendental, 'type)$
(%i17) put (%i, 'algebraic, 'type)$
(%i18) typeof (2*%e + x*%pi);
x is not numeric.
(%o18) [[transcendental, []], [algebraic, transcendental]]