MaplePrimes Commons General Technical Discussions

The primary forum for technical discussions.

The DFT windowing functions in the SignalProcessing package seem to be inconsistent in the type of data they will accept, and the type they return.

BartlettHannWindow,  BlackmanHarrisWindow, BlackmanNuttallWindow,   BohmanWindow, CauchyWindow, CosineWindow, ExponentialWindow, FlatTopWindow,  GaussianWindow, HannPoissonWindow, ParzenWindow, PoissonWindow,  RectangleWindow, ReiszWindow, RiemannWindow, TaperedCosineWindow, TriangleWindow, TukeyWindow

accept Arrays, containing almost any data type (haven't tried them all!) as input. and always return a Vector[row].

But

BartlettWindow, BlackmanWindow, HammingWindow, HannWindow, KaiserWindow

require that the option datatype=float[8] be set in the Array() constructor, which is used as input and always return an hfarray.

Thus, for example

with(SignalProcessing);
sig:= Array( -50..50,
                        fill=1
                    ):
BartlettHannWindow(sig); # this works
BartlettWindow(sig);# this fails with datatype unsupported error

Very confusing!!!!

As mentioned a few weeks back, we have been working on an update to MaplePrimes designed to dramatically curtail the amount of spam we have been receiving. I'm happy to say that we implemented these features earlier today, and in the hour or so since publication, they have already helped prevent multiple messages from being posted.

Using content posted to MaplePrimes over the past few months as a baseline, this new feature is successfully able to detect 90% of spam, while maintaining a false positive (i.e., incorrectly identifying a legitimate question or post) rate of 1%.

If a message is detected as spam, it is immediately quarantined and not publicly posted. Importantly, any user who posts a message seen as spam is immediately informed, and is provided with a simple mechanism to let us know so that their post can be reinstated (if it is in fact legimate.)

We will be closely monitoring these services to ensure that they are working as intended. In the meantime, I am very hopeful that they help improve the experience for our members, and require much less effort from our dedicated group of spam fighters.

Today we have published an update to MaplePrimes that includes a variety of improvements. Many of these changes are a direct result of member feedback and suggestions, and I am very appreciative for that!

What follows is a brief summary of the changes. As always, we remain very interested in your thoughts and feedback, and look forward to your further suggestions.

Also, a note that, as mentioned in a previous post, we have already begun working on a further update to address the influx of spam we have been receiving. This update will be published within the next 2-3 weeks.

Updated Look and feel
The most obvious change is the updated interface. With a few exceptions, the previous layout and functionality has been maintained, but with a cleaner, more responsive, and more appealing look.

New message editor
This update includes a new text editor called CKEditor. This editor provides a simpler, cleaner experience for posting your messages and also aligns MaplePrimes more closely with the Maplesoft product suite.

Notifications
You will notice a new flag icon in the upper right hand corner of the interface. This is the new MaplePrimes Notification feature, and it provides similar functionality to what we have become accustomed to on other social media sites. The icon is displayed in an orange color when you have notifications, and then when opened, your new notifications are highlighted in blue. Clicking on a notification will take you directly to the item being referenced.

Improved flow for removing spam messages
As any MaplePrimes moderator could tell you, removing spam on MaplePrimes was a cumbersome process taking 4 clicks. In this update, this process has been streamlined to 2 clicks, which will make the process considerably faster for our legion of spam fighters. In addition, the ability to remove spam is now available on all message types – comments, replies, etc.

Identification Badges
There are now 3 identification badges that are used throughout MaplePrimes wherever member information is displayed. These include:

 Denotes a member who works at Maplesoft

 Site moderators are the heart and soul of MaplePrimes, and are now identified by this new badge

 A member who also particpates in the Maple Ambassador Program

Other fixes and improvements
In addition to the changes mentioned above, several other minor fixes and improvements were made.

After days of fruitlessly searching the help files and the Internet for a means of converting a Dataseries of strings into numeric values in Maple I changed tack and determined how to do it myself.

I was surprised there was no built in Maple function to do this. From searching the Internet I can see I am not alone.
Since there are no other solutions on the net, here is mine:

toNumeric := (y) -> map(x->parse(x),y);

This creates the function toNumeric() that accepts a DataSeries of text values and returns it converted to a Dataseries of numeric values.

thing := DataSeries(["10", "20", "30", "55.9"], 'labels' = ["a", "b", "c", "d"]);
thing := toNumeric(thing); 

dataframething := DataFrame([["cow", "sheep", "goat", "alpaca"], ["10", "20", "30", "55.9"]], rows = ["a", "b", "c", "d"]);
dataframething[2] := toNumeric(dataframething[2]);


If you want to see this in Maple, try:
 typecastdataseries-maple




 

In order to change Maple for the better, I use to submit SCRs. However, as i was kindly
informed by Bryon (a copy of his e-letter on demand), MaplePrimes are under reconstruction and do not
work properly. At least my three messages sent through the Contact button were lost.
I have  unsuccessfully tried to reach beta.maplesoft.com (see the result of ping in the screen screen.29.08.16.docx).
Please, help me!

Bruce Jenkins is President of Ora Research, an engineering research and advisory service. Maplesoft commissioned him to examine how systems-driven engineering practices are being integrated into the early stages of product development, the results of which are available in a free whitepaper entitled System-Level Physical Modeling and Simulation. In the coming weeks, Mr. Jenkins will discuss the results of his research in a series of blog posts.

This is the first entry in the series.

Discussions of how to bring simulation to bear starting in the early stages of product development have become commonplace today. Driving these discussions, I believe, is growing recognition that engineering design in general, and conceptual and preliminary engineering in particular, face unprecedented pressures to move beyond the intuition-based, guess-and-correct methods that have long dominated product development practices in discrete manufacturing. To continue meeting their enterprises’ strategic business imperatives, engineering organizations must move more deeply into applying all the capabilities for systematic, rational, rapid design development, exploration and optimization available from today’s simulation software technologies.

Unfortunately, discussions of how to simulate early still fixate all too often on 3D CAE methods such as finite element analysis and computational fluid dynamics. This reveals a widespread dearth of awareness and understanding—compounded by some fear, intimidation and avoidance—of system-level physical modeling and simulation software. This technology empowers engineers and engineering teams to begin studying, exploring and optimizing designs in the beginning stages of projects—when product geometry is seldom available for 3D CAE, but when informed engineering decision-making can have its strongest impact and leverage on product development outcomes. Then, properly applied, systems modeling tools can help engineering teams maintain visibility and control at the subsystems, systems and whole-product levels as the design evolves through development, integration, optimization and validation.

As part of my ongoing research and reporting intended to help remedy the low awareness and substantial under-utilization of system-level physical modeling software in too many manufacturing industries today, earlier this year I produced a white paper, “System-Level Physical Modeling and Simulation: Strategies for Accelerating the Move to Simulation-Led, Systems-Driven Engineering in Off-Highway Equipment and Mining Machinery.” The project that resulted in this white paper originated during a technology briefing I received in late 2015 from Maplesoft. The company had noticed my commentary in industry and trade publications expressing the views set out above, and approached me to explore what they saw as shared perspectives.

From these discussions, I proposed that Maplesoft commission me to further investigate these issues through primary research among expert practitioners and engineering management, with emphasis on the off-highway equipment and mining machinery industries. In this research, focused not on software-brand-specific factors but instead on industry-wide issues, I interviewed users of a broad range of systems modeling software products including Dassault Systèmes’ Dymola, Maplesoft’s MapleSim, The MathWorks’ Simulink, Siemens PLM’s LMS Imagine.Lab Amesim, and the Modelica tools and libraries from various providers. Interviewees were drawn from manufacturers of off-highway equipment and mining machinery as well as some makers of materials handling machinery.

At the outset, I worked with Maplesoft to define the project methodology. My firm, Ora Research, then executed the interviews, analyzed the findings and developed the white paper independently of input from Maplesoft. That said, I believe the findings of this project strongly support and validate Maplesoft’s vision and strategy for what it calls model-driven innovation. You can download the white paper here.

Bruce Jenkins, Ora Research
oraresearch.com

This post is about the relationship between the number of processors used in parallel processing with the Threads package and the resultant real times and cpu times for a computation.

In the worksheet below, I perform the same computation using each possible number of processors on my machine, one thru eight. The computation is adding a list of 32 million pre-selected random integers. The real times and cpu times are collected from each run, and these are analyzed with a variety of metrics that I devised. Note that garbage-collection (gc) time is not an issue in the timings; as you can see below, the gc times are zero throughout.

My conclusion is that there are severely diminishing returns as the number of processors increases. There is a major benefit in going from one processor to two; there is a not-as-great-but-still-substantial benefit in going from two processors to four. But the real-time reduction in going from four processors to eight is very small compared to the substantial increase in resource consumption.

Please discuss the relevance of my six metrics, the soundness of my test technique, and how the presentation could be better. If you have a computer capable of running more than eight threads, please modify and run my worksheet on it.

Diminishing Returns from Parallel Processing: Is it worth using more than four processors with Threads?

Author: Carl J Love, 2016-July-30 

Set up tests

 

restart:

currentdir(kernelopts(homedir)):
if kernelopts(numcpus) <> 8 then
     error "This worksheet needs to be adjusted for your number of CPUs."
end if:
try fremove("ThreadsData.m") catch: end try:
try fremove("ThreadsTestData.m") catch: end try:
try fremove("ThreadsTest.mpl") catch: end try:

#Create and save random test data
L:= RandomTools:-Generate(list(integer, 2^25)):
save L, "ThreadsTestData.m":

#Create code file to be read for the tests.
fd:= FileTools:-Text:-Open("ThreadsTest.mpl", create):
fprintf(
     fd,
     "gc();\n"
     "read \"ThreadsTestData.m\":\n"
     "CodeTools:-Usage(Threads:-Add(x, x= L)):\n"
     "fd:= FileTools:-Text:-Open(\"ThreadsData.m\", create, append):\n"
     "fprintf(\n"
     "     fd, \"%%m%%m%%m\\n\",\n"
     "     kernelopts(numcpus),\n"
     "     CodeTools:-Usage(\n"
     "          Threads:-Add(x, x= L),\n"
     "          iterations= 8,\n"
     "          output= [realtime, cputime]\n"
     "     )\n"
     "):\n"
     "fclose(fd):"
):
fclose(fd):

#Code review
fd:= FileTools:-Text:-Open("ThreadsTest.mpl"):
while not feof(fd) do
     printf("%s\n", FileTools:-Text:-ReadLine(fd))
end do:

fclose(fd):

gc();
read "ThreadsTestData.m":
CodeTools:-Usage(Threads:-Add(x, x= L)):
fd:= FileTools:-Text:-Open("ThreadsData.m", create, append):
fprintf(
     fd, "%m%m%m\n",
     kernelopts(numcpus),
     CodeTools:-Usage(
          Threads:-Add(x, x= L),
          iterations= 8,
          output= [realtime, cputime]
     )
):
fclose(fd):

 

Run the tests

restart:

kernelopts(numcpus= 1):
currentdir(kernelopts(homedir)):
read "ThreadsTest.mpl":

memory used=0.79MiB, alloc change=0 bytes, cpu time=2.66s, real time=2.66s, gc time=0ns

memory used=0.78MiB, alloc change=0 bytes, cpu time=2.26s, real time=2.26s, gc time=0ns

 

Repeat above test using numcpus= 2..8.

 

restart:

kernelopts(numcpus= 2):
currentdir(kernelopts(homedir)):
read "ThreadsTest.mpl":

memory used=0.79MiB, alloc change=2.19MiB, cpu time=2.73s, real time=1.65s, gc time=0ns

memory used=0.78MiB, alloc change=0 bytes, cpu time=2.37s, real time=1.28s, gc time=0ns

 

restart:

kernelopts(numcpus= 3):
currentdir(kernelopts(homedir)):
read "ThreadsTest.mpl":

memory used=0.79MiB, alloc change=4.38MiB, cpu time=2.98s, real time=1.38s, gc time=0ns

memory used=0.78MiB, alloc change=0 bytes, cpu time=2.75s, real time=1.05s, gc time=0ns

 

restart:

kernelopts(numcpus= 4):
currentdir(kernelopts(homedir)):
read "ThreadsTest.mpl":

memory used=0.80MiB, alloc change=6.56MiB, cpu time=3.76s, real time=1.38s, gc time=0ns

memory used=0.78MiB, alloc change=0 bytes, cpu time=3.26s, real time=959.75ms, gc time=0ns

 

restart:

kernelopts(numcpus= 5):
currentdir(kernelopts(homedir)):
read "ThreadsTest.mpl":

memory used=0.80MiB, alloc change=8.75MiB, cpu time=4.12s, real time=1.30s, gc time=0ns

memory used=0.78MiB, alloc change=0 bytes, cpu time=3.74s, real time=910.88ms, gc time=0ns

 

restart:

kernelopts(numcpus= 6):
currentdir(kernelopts(homedir)):
read "ThreadsTest.mpl":

memory used=0.81MiB, alloc change=10.94MiB, cpu time=4.59s, real time=1.26s, gc time=0ns

memory used=0.78MiB, alloc change=0 bytes, cpu time=4.29s, real time=894.00ms, gc time=0ns

 

restart:

kernelopts(numcpus= 7):
currentdir(kernelopts(homedir)):
read "ThreadsTest.mpl":

memory used=0.81MiB, alloc change=13.12MiB, cpu time=5.08s, real time=1.26s, gc time=0ns

memory used=0.78MiB, alloc change=0 bytes, cpu time=4.63s, real time=879.00ms, gc time=0ns

 

restart:

kernelopts(numcpus= 8):
currentdir(kernelopts(homedir)):
read "ThreadsTest.mpl":

memory used=0.82MiB, alloc change=15.31MiB, cpu time=5.08s, real time=1.25s, gc time=0ns

memory used=0.78MiB, alloc change=0 bytes, cpu time=4.69s, real time=845.75ms, gc time=0ns

 

Analyze the data

restart:

currentdir(kernelopts(homedir)):

(R,C):= 'Vector(kernelopts(numcpus))' $ 2:
N:= Vector(kernelopts(numcpus), i-> i):

fd:= FileTools:-Text:-Open("ThreadsData.m"):
while not feof(fd) do
     (n,Tr,Tc):= fscanf(fd, "%m%m%m\n")[];
     (R[n],C[n]):= (Tr,Tc)
end do:

fclose(fd):

plot(
     (V-> <N | 100*~V>)~([R /~ max(R), C /~ max(C)]),
     title= "Raw timing data (normalized)",
     legend= ["real", "CPU"],
     labels= [`number of processors\n`, `%  of  max`],
     labeldirections= [HORIZONTAL,VERTICAL],
     view= [DEFAULT, 0..100]
);

The metrics:

 

R[1] /~ R /~ N:          Gain: The gain from parallelism expressed as a percentage of the theoretical maximum gain given the number of processors

C /~ R /~ N:               Evenness: How evenly the task is distributed among the processors

1 -~ C[1] /~ C:           Overhead: The percentage of extra resource consumption due to parallelism

R /~ R[1]:                   Reduction: The percentage reduction in real time

1 -~ R[2..] /~ R[..-2]:  Marginal Reduction: Percentage reduction in real time by using one more processor

C[2..] /~ C[..-2] -~ 1:  Marginal Consumption: Percentage increase in resource consumption by using one more processor

 

plot(
     [
          (V-> <N | 100*~V>)~([
               R[1]/~R/~N,             #gain from parallelism
               C/~R/~N,                #how evenly distributed
               1 -~ C[1]/~C,           #overhead
               R/~R[1]                 #reduction
          ])[],
          (V-> <N[2..] -~ .5 | 100*~V>)~([
               1 -~ R[2..]/~R[..-2],   #marginal reduction rate
               C[2..]/~C[..-2] -~ 1    #marginal consumption rate        
          ])[]
     ],
     legend= typeset~([
          'r[1]/r/n',
          'c/r/n',
          '1 - c[1]/c',
          'r/r[1]',
          '1 - `Delta__%`(r)',
          '`Delta__%`(c) - 1'       
     ]),
     linestyle= ["solid"$4, "dash"$2], thickness= 2,
     title= "Efficiency metrics\n", titlefont= [HELVETICA,BOLD,16],
     labels= [`number of processors\n`, `% change`], labelfont= [TIMES,ITALIC,14],
     labeldirections= [HORIZONTAL,VERTICAL],
     caption= "\nr = real time,  c = CPU time,  n = # of processors",
     size= combinat:-fibonacci~([16,15]),
     gridlines
);

 

 

Download Threads_dim_ret.mw

What's up with Mapleprimes's timing today? Every time I click on a Post or Question, the main post loads at the normal speed (which is slow to start with), and then it takes a full minute for the Answers or Replies (or lack thereof) to load. This has been consistent for every Post or Question that I've read today. Is anyone else experiencing this?

 

Points on the coordinate plane

(Guidance manual for the 6th class)

Changing the initial coordinates and going through the entire program first, we get a new picture-task

 

    Point_on_co-plane.mws

 

And Another     Coordinate_plane.mws

 

 

 

Coordinate axis

6th class (in Russia)

Guidance manual for use at lessons (at school)

Coordinate_line_lesson.mws

(It is possible bad English)

I have recently taken a few comments and questions about moderation, and thought it would be worthwhile to clarify our policies.

Although financed and hosted by Maplesoft, MaplePrimes is a community-run site. Our members provide thoughtful posts, answer thousands of questions each year, and generally keep things running smoothly by removing spam and moderating content. Moderation and management capabilities are granted automatically based on a member's reputation, which is a measure of how their content is valued by other community-members. Once someone's reputation score reaches 500, moderation privileges are granted. There are currently 69 members who have moderation capabilities.

We have had this system running for years, and by and large, it works well. There are occasional problems, of course, and these have been dealt with on an as-needed basis, and will continue to be dealt-with going forward.

What is the intent of moderation?

Quite simply, moderation capabilities are provided to maintain a high-standard of content. We want our moderators to help maintain a well organized and technically-sound site, without altering the intent or context of the original post.

Common examples of acceptable moderation scenarios include:

  • Removing spam or messages that violate our community guidelines
  • Editing the tags, categories or product(s) associated with a question or post
  • Correcting incorrect technical content such as bad URLs included in a post or poor formatting
  • Correcting a typo or improper spelling is appropriate in limited scenarios when the mistake made the original message confusing. In general practice, however, it is best to not edit someone else's grammar or spelling.

 

What is moderation not for?

MaplePrimes members cover a very diverse range of backgrounds, languages, technical skill with Maplesoft products, and familiarity with MaplePrimes. It is therefore normal that posts and questions within MaplePrimes reflect this diversity.

In order to respect the author, as well as to maintain the context of the original question or post, there are some scenarios where moderation should not be employed. For example:

  • Many members are not fluent in English, yet the context of their message/question is very clear. In cases like this, correcting improper spelling or grammar (unless requested) is disrespectful and should be avoided. 
  • Do not edit or remove another person's code, even if it is incorrect or incomplete. Doing so can completely change the context of the message and makes the message very confusing for people who read that thread in the future.
  • Do not edit the context of a message to make it 'read better'. Even if your intentions are good, edits like these are can be seen as disrespectful, and in some cases, even inflammatory.

In general, I recommend following this rule: If you're not 100% certain that your edit will be helpful and appreciated by everyone, do not make it.

 

What can I do if I disagree with a moderator's changes?

MaplePrimes moderators are invaluable for keeping MaplePrimes running smoothly, and as mentioned above, they do a great job. From time to time, however, a change may be made that you disagree with. Often such changes are a result of a misunderstanding on the part of the moderator, or perhaps just an honest mistake.

In situations like these, my recommendation is to contact MaplePrimes administrators by flagging the post as 'other' and providing the details. We will then look into the issue and (hopefully) reach a speedy resolution. During this process, we will contact the poster and/or the moderator to discuss the changes. If needed, further actions can be taken, from further education up to and including suspending or removing moderator privileges. 

 

I hope this has been helpful, and I'm looking forward to your thoughts and suggestions in the comments below.

Bryon

 

Russian children work with Maple - view

http://geodromchik.blogspot.ru

//sites.google.com/site/geodromchic

 

Bug_in_integrate.mw

M_Iwaniuk

The mechanism of transport of the material of the sewing machine M 1022 class: mathematical animation.   BELORUS.mw 




I thought I would share some code for computing sparse matrix products in Maple.  For floating point matrices this is done quickly, but for algebraic datatypes there is a performance problem with the builtin routines, as noted in http://www.mapleprimes.com/questions/205739-How-Do-I-Improve-The-Performance-Of

Download spm.txt

The code is fairly straightforward in that it uses op(1,A) to extract the dimensions and op(2,A) to extract the non-zero elements of a Matrix or Vector, and then loops over those elements.  I included a sparse map function for cases where you want to map a function (like expand) over non-zero elements only.

# sparse matrix vector product
spmv := proc(A::Matrix,V::Vector)
local m,n,Ae,Ve,Vi,R,e;
n, m := op(1,A);
if op(1,V) <> m then error "incompatible dimensions"; end if;
Ae := op(2,A);
Ve := op(2,V);
Vi := map2(op,1,Ve);
R := Vector(n, storage=sparse);
for e in Ae do
n, m := op(1,e);
if member(m, Vi) then R[n] := R[n] + A[n,m]*V[m]; end if;
end do;
return R;
end proc:
# sparse matrix product
spmm := proc(A::Matrix, B::Matrix)
local m,n,Ae,Be,Bi,R,l,e,i;
n, m := op(1,A);
i, l := op(1,B);
if i <> m then error "incompatible dimensions"; end if;
Ae := op(2,A);
Be := op(2,B);
R := Matrix(n,l,storage=sparse);
for i from 1 to l do
Bi, Be := selectremove(type, Be, (anything,i)=anything);
Bi := map2(op,[1,1],Bi);
for e in Ae do
n, m := op(1,e);
if member(m, Bi) then R[n,i] := R[n,i] + A[n,m]*B[m,i]; end if;
end do;
end do;
return R;
end proc:
# sparse map
smap := proc(f, A::{Matrix,Vector})
local B, Ae, e;
if A::Vector then
B := Vector(op(1,A),storage=sparse):
else
B := Matrix(op(1,A),storage=sparse):
end if;
Ae := op(2,A);
for e in Ae do
B[op(1,e)] := f(op(2,e),args[3..nargs]);
end do;
return B;
end proc:


As for how it performs, here is a demo inspired by the original post.

n := 674;
k := 6;
A := Matrix(n,n,storage=sparse):
for i to n do
  for j to k do
    A[i,irem(rand(),n)+1] := randpoly(x):
  end do:
end do:
V := Vector(n):
for i to k do
  V[irem(rand(),n)+1] := randpoly(x):
end do:
C := CodeTools:-Usage( spmv(A,V) ):  # 7ms, 25x faster
CodeTools:-Usage( A.V ):  # 174 ms
B := Matrix(n,n,storage=sparse):
for i to n do
  for j to k do
    B[i,irem(rand(),n)+1] := randpoly(x):
  end do:
end do:
C := CodeTools:-Usage( spmm(A,B) ):  # 2.74 sec, 50x faster
CodeTools:-Usage( A.B ):  # 2.44 min
# expand and collect like terms
C := CodeTools:-Usage( smap(expand, C) ):
4 5 6 7 8 9 10 Last Page 6 of 78