mmcdara

7891 Reputation

22 Badges

9 years, 60 days

MaplePrimes Activity


These are replies submitted by mmcdara

@Preben Alsholm 

Thank you Preben.
I had done the first step but wasn't capable to go further.

A question: 

# Why did you use
select(hastype,expr,specfunc(piecewise));
# instead of
select(has,expr,piecewise);
# ?

... and another one:
Can you explan me how  does And(relation,satisfies(r->lhs(r)=t)) work?

select(hastype,expr,specfunc(piecewise)):
map(u -> hastype(u, And(relation,satisfies(r->lhs(r)=t))), [op(%)])
                   [false, true, true, true]

 

@Ramakrishnan 

Ok, see you next time

@acer 

Thank you acer for this detailed answer.
I agree that developping a procedure which pretty-prints general expressions is probably a hard task (mainly because of bracketing) and a waste of time.
My question to @vv was more motivated by curiosity than by an imperative need.

thank you both @acer and @vv for reminding me the existence of neutral operators...

@acer 

Thanks.
Don't worry about the version, I'll have my professional 2021 back very soon.

@vv 

Same reply as @tomleslie "Of course you are correct!"

By the way, do you know is there exists something to display a ligical proposition in a more "readable.consise" form?
Something like this...

rew := {
  Logic:-`&and` = `#mo("⋀")`,
  Logic:-`&or`  = `#mo("⋁")`,
  Logic:-`&not` = `#mo("¬")`
}:

a &and &not(a &or b);

eval(%, rew)

...or whether it is to be done in an ad hoc manner?

Last question: by simple curiosity, what is the process that makes something like Logic:-`&and`(a, b)
to be displayed a &and b and not &and(a, b)?

@Carl Love 

Your 2 functions are identically null over the domain x=0..2, y=0..1 (and I do not think it is what @Ramakrishnan wants?)
More of this they take different values over domains of the form x=a..0, y=a..0 (a < 0) where f2 remains identically null.

What I would have done, given my interpretation of the question, is this

S := (a, b, u, v, f) -> `if`(verify(u, a, interval) and verify(v, b, interval), f, 0);
plot3d('S(0..1, 0..1, x, y, x+y)+S(1..2, 0..1, x, y, x-y)', x=-1..3, y=-1..2);

... but it's just my interpretation and @Ramakrishnan seems happy with what you did 

@vv 

An very slight improvement (?)
 

restart;
f:=(exp(x^2)+exp(1))/(exp(x^2)-exp(1))+3;
b:=0: p:=0: q:=eval(f, x=0)+r: a:=-c;
circ := (x-p)^2+(y-q)^2-r^2: F:=unapply(eval(circ, y=f), x):
sys:=numer(simplify([F(c), D(F)(c)])):
fsolve(sys);

 

@vv 

Thank you for this intelligent and necessary (it successfully handle my first test case) reappropriation
(I hope this last term is the good one for its meanings in French and English seem to diverge slightly)

 I vote up

@nmacsai 

Another comment
If you have to open/close your csv file multiple times, it's worth saving it as a binary file and using that afterwards .
Note that @Carl Love's answer essentially raises the main question. 

@Carl Love 

"That depends on who's doing the recommending"

People who are used to handling  big data files generally agree on the point that CSV files are not optimal from the point of view of efficiency (red/write time and memory size).
For archiving (even if I do not understand what you mean), there exist more efficient file format than csv, for instance JSON or NetCDF to say a few (which is a binary self domumented format which can handle complex data structures).

See here big-data-file-formats-explained-dfaabe9e8b33 for instance

From my own experience (shared with many of my coworkers) I (most of us) think that a lot of people keep using CSV files or alike just because they can "see" what these files contain and that this reassures them.

What is funny is that you critize my comment about prefering binary format and that at the same time your answer to the @nmacsai  is based upon m files (which are binary files), thus implicitely considering binary format would be a better solution than csv.

 

Just a comment...
As a general rule, regardless of the language used, it is not recommended to work with csv files this size.
It is much more efficient to use binary files instead.

@kiraMou 

Sorry, I didn't read carefully enough.
To make up for it, here are some further details that might interest you:
solutions.mw

@kiraMou 

I thought you wanted solutions whose imaginary parts were in the range 0.5..1 for x[1] and x[2] and in the range -1..-0.5 for x[3] and x[4]?

The solution you give obviously does not meet these requirements.

Do I missed something?

@acer 

Happy to hear that it works for recent versions. So I just have to wait until I'm back in the office. In the meantime, I'll do something else.
Thank you

The first version is the faster than the two (not necessaily the tastest in absolute)
perf.mw
 

restart:

interface(version)

`Standard Worksheet Interface, Maple 2015.2, Mac OS X, December 21 2015 Build ID 1097895`

(1)

N   := 1000:
r   := rand(1..N):
L   := [seq(r(), k=1..N)]:
ind := [seq(r(), k=1..N)]:

f := proc(L, N)
  local ind := [seq(r(), k=1..N)]:
  return L[ind]
end proc:

CodeTools:-Usage(f(L, N), iterations=100):

memory used=15.84KiB, alloc change=0 bytes, cpu time=320.00us, real time=320.00us, gc time=0ns

 

with(Threads):
f := proc(L, N)
  local ind := [seq(r(), k=1..N)]:
  return Map(w->L[w],ind)
end proc:

CodeTools:-Usage(f(L, N), iterations=100):

memory used=76.12KiB, alloc change=6.56MiB, cpu time=1.40ms, real time=690.00us, gc time=0ns

 

f := proc(L)
  local res:=NULL:
  local n:
  local ind := [seq(r(), k=1..N)]:
  for n from 1 to nops(N) do
    res := res, L[ind[n]]
  end do:
  return res
end proc:

CodeTools:-Usage(f(L,ind), iterations=100):

memory used=8.12KiB, alloc change=512.00KiB, cpu time=360.00us, real time=370.00us, gc time=0ns

 

f := proc(L, N)
  local ind := [seq(r(), k=1..N)]:
  return L[ind]
end proc:

CodeTools:-Usage(f(L, N), iterations=100):

memory used=15.84KiB, alloc change=0 bytes, cpu time=320.00us, real time=320.00us, gc time=0ns

 

with(Threads):
f := proc(L, N)
  local ind := [seq(r(), k=1..N)]:
  return Map(w->L[w],ind)
end proc:

CodeTools:-Usage(f(L, N), iterations=100):

memory used=76.12KiB, alloc change=6.56MiB, cpu time=1.40ms, real time=690.00us, gc time=0ns

 

# with no rebuild of ind

ind := [seq(r(), k=1..N)]:

f := proc(L, ind)
  return L[ind]
end proc:
CodeTools:-Usage(f(L,ind), iterations=100):

f := proc(L, ind)
  return Map(w->L[w],ind)
end proc:
CodeTools:-Usage(f(L,ind), iterations=100):

memory used=7.90KiB, alloc change=0.78MiB, cpu time=20.00us, real time=20.00us, gc time=0ns
memory used=68.05KiB, alloc change=360.00KiB, cpu time=1.04ms, real time=350.00us, gc time=35.61us

 

 


 

Download perf.mw

 

First 83 84 85 86 87 88 89 Last Page 85 of 154