Alec Mihailovs

Dr. Aleksandrs Mihailovs

4455 Reputation

21 Badges

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

Social Networks and Content at Maplesoft.com

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

When this post was a question (about an hour ago), it had 5 answers - one Paulina's and 4 mine. What happened with them?

_______________
Alec Mihailovs, PhD

"since like Maple it is written in Java"

I never thought about Maple as of something written in Java.

I'd like to second the Roman Pearce's suggestion - there is a significant difference in quality between Maple's and Minecraft's images.

_______________
Alec Mihailovs, PhD

@acer 

Just a note clarifying the answer a little bit,

GAMMA(13/2);
                                     1/2
                             10395 Pi
                             -----------
                                 64

Alec

@acer 

Just a note clarifying the answer a little bit,

GAMMA(13/2);
                                     1/2
                             10395 Pi
                             -----------
                                 64

Alec

Nice to hear that me stopping posting here was not a big loss to the community.

I didn't read this site for a while and am out of the current events. Who is that person you were specifically referring to?

_______________
Alec Mihailovs, PhD

If "someone well know here" is supposed to be me, then downthumbs have contributed only a small part to the situation leading me to stopping posting here,

In general, I don't like the way the site looks and functions right now, with downthumbs or without them. The previous version of the site, with all of its problems, still was significantly better.

_______________
Alec Mihailovs, PhD

Now, out of 1532 views of this post at this moment I got only 6 votes up? 1526 were neutral? And I got only 8 votes up for my another recent post with 1401 views? Well, it is better than a couple (or 3, 4) months ago, when my similar posts got voted 2 or 3 times down and 0 up - but still... Who are reading this and why possibly could I be interested in continuing posting here? That's not much of a motivation (and not much of a community.)

Will Maplesoft add CDECL to define_external if they didn't do that for last 10 or 20 years in spite of multiple requests for that from tons of users - the same, as, say, for plot exports in png or svg that everybody else had? Nah, unbelievable.

They'd rather add another IsEodermdrome instead (which, I admit, I may be the only one who don't care about and other 1531 readers of this post do) - you have to add something to make the next Maple version different from the previous one - otherwise who would buy it? - and if you are not able to add what everybody else have and what people want, you add what you are able to produce - that's better than nothing?!

I'm pretty much happy with Python. See you in 3 or 4 months (hopefully) for another try, guys (and, perhaps, gals), but frankly, I get less and less interested in Maple every (what?) unit of time.

_______________
Alec Mihailovs, PhD
Maplesoft Member

You could add a width parameter to the printf, something like printf("%5.2f",F);

_______________
Alec Mihailovs, PhD
Maplesoft Member

You could add a width parameter to the printf, something like printf("%5.2f",F);

_______________
Alec Mihailovs, PhD
Maplesoft Member

@Axel Vogt It's just copying and pasting, with adding another int, or changing int to double - not that hard. Producing delegates.c could be also done using a simple script in one of scripting languages - such as Python, Lua, Ruby, or Perl, or even in Maple (as Joe Riel did for one scripting task in a comment to one of John May's posts - the order of comments there in this Mapleprimes version is significantly different than it was originally). On the other hand, I don't see how a wrapper could be useful for that - it has everything in a different format.

I thought about that, and I thought that it could be done shorter with including <stdarg.h> in C or <cstdarg> in C++, it would involve string parsing - such as converting "int" to int, "int*" to int* etc. - which could be done with map in C++, but the problem is that typedef for myProc should be defined before the function is called, because it is a part of one of its arguments. It is also possible to define all the types as void* initially, but then there is a problem of moving the parameters from va_list to the arguments of the function called with __cdecl - it is not that easy, especially if the types of these parameters are different. And calling such a thing from Maple would be more complicated.

Alec

@Axel Vogt Perhaps - I didn't try that. Looking into the Maple generated wrapper could be useful for adding such things to delegetes.c, so that the corresponding functions could be called later without using WRAPPER in define_external. Do you have some particular example in mind, to play with?

Alec

@Axel Vogt That an interesting idea (in cplx_GSL) - instead of writing a wrapper for every function, you wrote a wrapper for their signatures - say one for complex input, complex output, one for real input, complex output etc. - like delegates in C#. That's significantly shorter than writing a wrapper for every special function there.

So I could build delegates.dll from the following code,

typedef int (__cdecl *IntProcInt)(int);
typedef int (__cdecl *IntProcIntInt)(int, int);

__declspec(dllexport) int _stdcall IntCallInt(
    IntProcInt myProc, int myInt){
	
	return (myProc)(myInt);
}

__declspec(dllexport) int _stdcall IntCallIntInt(
    IntProcIntInt myProc, int myInt0, int myInt1){
	
	return (myProc)(myInt0, myInt1);
}

(and so on, covering needed signatures), then define them in Maple in addition to Load Library, GetProccAddress, and FreeLibrary definitions above as

IntCallInt:=define_external('IntCallInt',
    'myProc'::integer[4],
    'myInt'::integer[4],
    'RETURN'::integer[4],
    'LIB'="delegates.dll"):
IntCallIntInt:=define_external('IntCallIntInt',
    'myProc'::integer[4],
    'myInt0'::integer[4],
    'myInt1'::integer[4],
    'RETURN'::integer[4],
    'LIB'="delegates.dll"):

and use them after that as

gsl:=LoadLibrary("libgsl"):
id:=curry(IntCallInt,GetProcAddress(gsl,"gsl_permutation_calloc")):
s:=id(3):
elem:=curry(IntCallIntInt,GetProcAddress(gsl,"gsl_permutation_get")):
[seq](elem(s,i),i=0..2);

                              [0, 1, 2]

FreeLibrary(gsl):

That's neat!

Still, having a CDECL option in define_external would be much easier to use and would save a lot of work. FASTCALL also might be useful - see an example where I used the same technique with __fastcall.

Alec

Few steps could be done manually:

LoadLibrary:=define_external('LoadLibraryA',
    'lpFileName'::string,
    'RETURN'::integer[4],
    'LIB'="kernel32.dll"):
GetProcAddress:=define_external('GetProcAddress',
    'hModule'::integer[4],
    'lpProcName'::string,
    'RETURN'::integer[4],
    'LIB'="kernel32.dll"):
FreeLibrary:=define_external('FreeLibrary',
    'hModule'::integer[4],
    'RETURN'::boolean[4],
    'LIB'="kernel32.dll"):

and now I can determine the procedure address,

gsl:=LoadLibrary("libgsl");

                           gsl := 66060288

GetProcAddress(gsl,"gsl_permutation_calloc");

                               66672352

FreeLibrary(gsl);

                                 true

but there doesn't seem to be a simple way of calling a function by its address, with passing also parameters.

_______________
Alec Mihailovs, PhD
Maplesoft Member

@Axel Vogt Exactly. __stdcall and __cdecl differ in who is cleaning the stack - the caller or the callee. So using integer output which pops out of the stack creates a problem. If the output is float or double, it comes from a different place (FPU), and that doesn't reflect on it - and what is on the stack at that moment, doesn't matter (well, almost - that still may crash some other program, as well as Maple, so doiing that is still dangerous.)

Alec

@Joliver What if you get 2.5? Will you round it to 2 or to 3?

Alec

First 14 15 16 17 18 19 20 Last Page 16 of 180