Alec Mihailovs

Dr. Aleksandrs Mihailovs

4485 Reputation

21 Badges

20 years, 141 days
Mihailovs, Inc.
Owner, President, and CEO
Tyngsboro, Massachusetts, United States

Social Networks and Content at Maplesoft.com

Maple Application Center

I received my Ph.D. from the University of Pennsylvania in 1998 and I have been teaching since then at SUNY Oneonta for 1 year, at Shepherd University for 5 years, at Tennessee Tech for 2 years, at Lane College for 1 year, and this year I taught at the University of Massachusetts Lowell. My research interests include Representation Theory and Combinatorics.

MaplePrimes Activity


These are replies submitted by Alec Mihailovs

Yes, that means that the function was not exported. There are a few ways of making sure that a function is exported. One of them, in Open Watcom compiler, is to define a function f1 in your C code as
extern __declspec(dllexport) int __stdcall f1( 
with correct function type instead of int (something like double, maybe - depending on the function). The Compile script in one of the messages above has a typo - it should be %s.obj instead of %s in the middle of the linker command. Also, in most cases, linking with Maple's libraries is not necessary, so the dll can be produced by the following 2 commands,
wcl386 -c -bd NAME.c 

wlink system nt_dll file NAME.obj
with replacing NAME with the name of the file with your C code. See an example in my blog.
Yes, that means that the function was not exported. There are a few ways of making sure that a function is exported. One of them, in Open Watcom compiler, is to define a function f1 in your C code as
extern __declspec(dllexport) int __stdcall f1( 
with correct function type instead of int (something like double, maybe - depending on the function). The Compile script in one of the messages above has a typo - it should be %s.obj instead of %s in the middle of the linker command. Also, in most cases, linking with Maple's libraries is not necessary, so the dll can be produced by the following 2 commands,
wcl386 -c -bd NAME.c 

wlink system nt_dll file NAME.obj
with replacing NAME with the name of the file with your C code. See an example in my blog.
The simplest formula that I got is
Vt = 2/3*(6*Hr*Hl+3*Hr^2+V^2)^(1/2)*cos(1/3*Pi
+1/3*arccos(V*(-9*Hr*Hl+9*Hr^2-V^2)/(6*Hr*Hl+3*Hr^2+V^2)^(3/2)))+1/3*V
Vt = 2/3*(6*Hr*Hl+3*Hr^2+V^2)^(1/2)*cos(1/3*Pi+1/3*arccos(V*(-9*Hr*Hl+9*Hr^2-V^2)/(6*Hr*Hl+3*Hr^2+V^2)^(3/2)))+1/3*V Correspondingly,
X = 2*arctan(Vt/Hr)
X = 2*arctan(Vt/Hr) Other 2 solutions can be obtained by replacing Pi/3 with Pi and -Pi/3.
The simplest formula that I got is
Vt = 2/3*(6*Hr*Hl+3*Hr^2+V^2)^(1/2)*cos(1/3*Pi
+1/3*arccos(V*(-9*Hr*Hl+9*Hr^2-V^2)/(6*Hr*Hl+3*Hr^2+V^2)^(3/2)))+1/3*V
Vt = 2/3*(6*Hr*Hl+3*Hr^2+V^2)^(1/2)*cos(1/3*Pi+1/3*arccos(V*(-9*Hr*Hl+9*Hr^2-V^2)/(6*Hr*Hl+3*Hr^2+V^2)^(3/2)))+1/3*V Correspondingly,
X = 2*arctan(Vt/Hr)
X = 2*arctan(Vt/Hr) Other 2 solutions can be obtained by replacing Pi/3 with Pi and -Pi/3.
Changing Comment to Comment@op annihilates quotes. The semicolon is still there. A problem is that a comment cannot be the last statement in the procedure. With function type anything::anything, the procedure is not translated in this case; and with changing it to anything::void (or other valid C type), the last comment becomes the function return.
Sure. I would write it quite differently by hand :) I did some manual editing after that and it can't be opened in Maplet Buider though.
For example,
with (Maplets[Elements]):
maplet := 
Maplet('onstartup'='Action1','reference'='Maplet1',
	Label('background'="#D6D3CE",'caption'="g_compts[1,1]",'enabled'='true','foreground'="#000000",'reference'='Label1','visible'='true'),
	TextField('background'="#FFFFFF",'editable'='true','enabled'='true','foreground'="#000000",'halign'='left','reference'='TextField1','value'="1-2*m/r",'visible'='true','width'='30'),
	BoxLayout('background'="#D6D3CE",'border'='false','halign'='center','inset'='5','reference'='BoxLayout2','valign'='center','vertical'='true','visible'='true',
		BoxRow(
			BoxCell('hscroll'='never','value'='Label1','vscroll'='never'),
			BoxCell('hscroll'='never','value'='TextField1','vscroll'='never'))),
	Label('background'="#D6D3CE",'caption'="g_compts[2,2]",'enabled'='true','foreground'="#000000",'reference'='Label2','visible'='true'),
	TextField('background'="#FFFFFF",'editable'='true','enabled'='true','foreground'="#000000",'halign'='left','reference'='TextField2','value'="-1/(1-2*m/r)",'visible'='true','width'='30'),
	BoxLayout('background'="#D6D3CE",'border'='false','halign'='center','inset'='5','reference'='BoxLayout3','valign'='center','vertical'='true','visible'='true',
		BoxRow(
			BoxCell('hscroll'='never','value'='Label2','vscroll'='never'),
			BoxCell('hscroll'='never','value'='TextField2','vscroll'='never'))),
	Label('background'="#D6D3CE",'caption'="g_compts[3,3]",'enabled'='true','foreground'="#000000",'reference'='Label3','visible'='true'),
	TextField('background'="#FFFFFF",'editable'='true','enabled'='true','foreground'="#000000",'halign'='left','reference'='TextField3','value'="-r^2",'visible'='true','width'='30'),
	BoxLayout('background'="#D6D3CE",'border'='false','halign'='center','inset'='5','reference'='BoxLayout4','valign'='center','vertical'='true','visible'='true',
		BoxRow(
			BoxCell('hscroll'='never','value'='Label3','vscroll'='never'),
			BoxCell('hscroll'='never','value'='TextField3','vscroll'='never'))),
	Label('background'="#D6D3CE",'caption'="g_compts[4,4]",'enabled'='true','foreground'="#000000",'reference'='Label4','visible'='true'),
	TextField('background'="#FFFFFF",'editable'='true','enabled'='true','foreground'="#000000",'halign'='left','reference'='TextField4','value'="-r^2*sin(theta)^2",'visible'='true','width'='30'),
	BoxLayout('background'="#D6D3CE",'border'='false','halign'='center','inset'='5','reference'='BoxLayout5','valign'='center','vertical'='true','visible'='true',
		BoxRow(
			BoxCell('hscroll'='never','value'='Label4','vscroll'='never'),
			BoxCell('hscroll'='never','value'='TextField4','vscroll'='never'))),
	Action('reference'='clickButton1',
		Evaluate('function'='MathML:-Export(op(tensor[create]([-1,-1],array([[TextField1,0,0,0],[0,TextField2,0,0],[0,0,TextField3,0],[0,0,0,TextField4]]))))','target'='MathMLViewer1','waitforresult'='true')),
	Button('background'="#D6D3CE",'caption'="Create tensor",'enabled'='true','foreground'="#000000",'onclick'='clickButton1','reference'='Button1','visible'='true'),
	MathMLViewer('background'="#FFFFFF",'fontsize'='12','foreground'="#000000",'height'='180','reference'='MathMLViewer1','width'='500'),
	BoxLayout('background'="#D6D3CE",'border'='false','halign'='center','inset'='5','reference'='BoxLayout1','valign'='center','vertical'='false','visible'='true',
		BoxColumn(
			BoxCell('hscroll'='never','value'='BoxLayout2','vscroll'='never'),
			BoxCell('hscroll'='never','value'='BoxLayout3','vscroll'='never'),
			BoxCell('hscroll'='never','value'='BoxLayout4','vscroll'='never'),
			BoxCell('hscroll'='never','value'='BoxLayout5','vscroll'='never'),
			BoxCell('hscroll'='never','value'='Button1','vscroll'='never'),
			BoxCell('hscroll'='never','value'='MathMLViewer1','vscroll'='never'))),
	Window('layout'='BoxLayout1','reference'='Window1','resizable'='true','title'="Create Tensor"),
	Action('reference'='Action1',
		RunWindow('window'='Window1'))):

Maplets[Display](maplet);
Very interesting! I like a picture with the opposite colors, too,
img1:=evalhf(map(x->(1-x)^2,img_edge)):
Write("edge1.jpg",img1);
Another nice picture can be obtained if we won't use abs, i.e. defining
edge := img_x+img_y;
For example,
plots[display](plottools[line]([5,0],[5,10]),color=red);
or using PLOT structure,
PLOT(CURVES([[5, 0], [5, 10]]),COLOR(RGB,1,0,0));
Amanda, If you need just to display it, the simplest way to do that is
`property/ConvertRelation`:=()->FAIL:
vf:=piecewise(3*vx[1] < [6, 1] and vx[1] < [-2, 5], [3, 4]+3*vx[1],
              2*vx[1] < [8, -4] and -vx[1] < [2, -5], [1, 9]+2*vx[1], 
              -3*vx[1] < [-6, -1] and -2*vx[1] < [-8, 4], [9, 5]); 
Amanda, If you need just to display it, the simplest way to do that is
`property/ConvertRelation`:=()->FAIL:
vf:=piecewise(3*vx[1] < [6, 1] and vx[1] < [-2, 5], [3, 4]+3*vx[1],
              2*vx[1] < [8, -4] and -vx[1] < [2, -5], [1, 9]+2*vx[1], 
              -3*vx[1] < [-6, -1] and -2*vx[1] < [-8, 4], [9, 5]); 
Slowness in these examples with evalhf is caused partially by a wrong using of evalhf - it should be not inside the expression, but outside,
B:=evalhf(zip(`/`, X, Y));
and
C:=evalhf(map(log, XCopy));
work much faster. In general, map is quite fast.
It looks as if comments can be edited if nobody replied to them and can't be edited otherwise.
Now, when we calculated the maximal number of digits for different bases, the numbers with these number of digits also can be calculated. Here is the correspondingly changed procedure,
a7 := proc(b::integer[4], A::Array(datatype = integer[4]),
    N::integer[4])::integer[4];
local i::integer[4], j::integer[4], s::integer[4], r::integer[4];
    A[1] := 1;
    i := 2;
    s := 1;
    while 0 < i do
        if i = N + 1 then printf("%d\n", A)
        end if;
        if s = 1 then
            r := irem(A[1], i);
            for j from 2 to i - 1 do r := irem(r*b + A[j], i)
            end do;
            r := irem(r*b, i);
            if r = 0 then A[i] := 0; i := i + 1
            elif b - 1 + r < i then i := i - 1; s := 0
            else A[i] := i - r; i := i + 1
            end if
        else
            if A[i] + i < b then
                A[i] := A[i] + i; i := i + 1; s := 1
            else i := i - 1
            end if
        end if
    end do
end proc:

a8:=Compiler:-Compile(a7):
A:=Array(1..100,datatype=integer[4]):
This procedure called as a8(b,A,N) prints all N-digit numbers in base b satisfying the problem conditions. Here are the new numbers produced by it, written as sequences of their digits in base b.
a8(17,A[1..45],45):
9 7 10 6 3 9 1 11 10 14 13 11 3 5 2 14 0 10 15 11 8
8 10 2 4 0 2 2 6 4 12 2 8 0 10 10 11 5 3 1 13 3 2 6 13 

a8(18,A[1..48],48):
10 14 6 16 10 0 7 10 9 14 10 0 4 2 3 2 2 0 16 16 15 6 16 0 14 4 9 2 16
12 6 4 0 0 16 0 13 4 0 8 3 0 8 0 0 6 14 12 

a8(19,A[1..48],48):
4 16 10 2 4 0 12 4 2 10 11 15 10 18 17 13 6 8 0 10 2 16 10 16 10 18 17
13 18 14 17 17 2 2 10 6 12 0 9 5 9 7 7 9 5 7 11 9 
15 7 11 11 17 11 12 6 0 0 10 14 4 12 2 14 1 15 0 2 1 9 16 8 10 18 8 0
7 17 14 0 13 1 4 16 16 0 5 5 2 2 0 12 12 12 6 18 

a8(20,A[1..52],52):
17 16 8 16 5 4 6 8 2 0 12 0 0 6 0 16 1 12 4 0 2 0 6 0 0 18 12 0 10 10
16 0 11 6 0 12 18 12 0 0 16 10 16 8 10 18 14 8 15 0 12 12 

a8(21,A[1..53],53):
12 16 12 0 0 12 14 6 9 9 18 0 11 7 9 5 0 18 10 12 0 10 12 18 5 13 6 0
8 18 18 0 0 18 14 12 14 0 0 14 4 0 20 8 3 19 9 9 7 11 3 11 0 
17 1 0 2 15 3 7 7 6 2 3 9 6 14 18 2 18 18 14 18 0 6 17 9 8 6 18 0 18
18 13 19 0 6 7 15 0 12 3 5 14 0 20 6 0 14 8 18 14 16 15 11 18 
fprintf gives the best formatting options. Also, ExportMatrix can be used (especially for data in Matlab format). For example, in its simple form,
A:=Matrix(10,3,(i,j)->rhs(dsol1(0.1*i)[j])):
ExportMatrix("data.txt",A):
First 174 175 176 177 178 179 180 Page 176 of 180