Carl Love

Carl Love

28055 Reputation

25 Badges

12 years, 364 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are replies submitted by Carl Love

How do you use ifelse? I can find no documentation, nor does eval(ifelse) return anything useful.

@Les When you're entering or editing the Question, there's a pull-down menu that lists Maple, MapleSim, MapleTA, MaplePrimes, etc.---the various Maplesoft products that are discussed on this forum. While the vast majority of the discussion here is about Maple itself, there are occasionally Questions about the others.

@Les The single quotes are used to guard against the possibility that elsewhere in your code you assigned a value to color, linestyle, spacedash, etc. If you've not assigned values to any of those, then the quotes make no difference. If you want to get even more fussy about it, you can make them, for example, ':-color', which would also guard against the possibility that the code is embedded in other code where color is used as a local variable.

To deal with indexed names and functions in the most general way, I think that it's necessary to localize the names (symbols) before they are assigned values. Like this:

RootSymbol:= (e::{symbol, indexed, function})-> `if`(e::symbol, e, thisproc(op(0,e))):
     
Localize:= proc(e)
local S:= RootSymbol~(indets(e, {symbol, indexed, function}));
     subs(S =~ convert~(S, `local`), e)
end proc:

Define your list or vector of column headers/entries:
Exprs:= [a, b(23)[34], c[b[a]^2+1]];

Headers:= Localize(Exprs):
a:= 1:  b:= B:  c:= f:
Matrix([Headers, Exprs]);

Now you can change the values of a, b, c at will, and the Headers will never change.

@rostam And do you have the same anti-aliasing setting on your laptop and PC? Use the menu Tools -> Options -> Display -> Plot anti-aliasing.

@Thomas Dean There's some (inadequte) discussion of using infix operators in prefix form at ?use. The operators that can be used in prefix form are `..`, `@`, `@@`, `.`, `+`, `*`, `-`, `/`, `mod`, `^`, `!`, `union`, `minus`, `intersect`, `subset`, `in`, `$`, `and`, `or`, `not`, `xor`, `implies`, `=`, `<>`, `<`, `<=`, `>`, `>=`, `assuming`, `<|>`, `<,>`, `[]`, `{}`, `?()`, `?[]`, and `~`. The sematics of and, or, and implies are slightly different in prefix form: They don't obey the McCarthy rules (perhaps this has been corrected in Maple 2016.1a; I haven't had a chance to check yet).

@Thomas Dean Please look closely to see the difference with and without the leading `=`. It's the same as the difference between a,b and a=b.

Also, pay heed to Kitonum's correction of my unfortunate mistake. I neglected the minus sign that comes from moving from one side of the equation to the other.

@Thomas Dean That's completely separate from this Question. Please ask it as a new Question, not as an irrelevant Reply to another Question. A Reply is meant to be a response to the material that precedes it.

@roman_pearce How'd you get Maple to say that the system is inconsistent? And if it is, why did I get a result from the command in my Answer (using Maple 16)? Are you sure that you used the correct variable names? It was a little tricky for me to get them right.

Axel and Acer, please see my Answer in the original thread, where I use the `property/object` table to get the intersection of intervals.

@sand15 That was my Answer. I deleted it because on a subsequent reading I decided that it didn't properly address the Question. That's because it only determined whether the intervals have nonempty intersection rather than finding what the intersection was.

I'll put the Answer back on the other Question. Sorry for the confusion.

Please post your worksheet as an attached file. The parts of your post that aren't plaintext can't be copy-and-pasted.

Also, distance and distancevector are used in your code and are never defined.

@Kitonum 

I excluded 0 from the allowed input for the multiplier in addition thinking that that case was never useful (the output being the identity). It's a waste to do the matrix multiplication when the elementary matrix is the identity, so the call to addition should not be done when the multiplier is 0. That makes the code

reduced:= proc(B::Matrix)
uses LA= LinearAlgebra;
local
     M:= B, l:= 1, #l is current column.
     m:= LA:-RowDimension(M), n:= LA:-ColumnDimension(M), i, j
;
     for i to m do   #going through every row item
          #l needs to be less than column number n.
          if n < l then return M end if;
          j:= i;   #Initialize current row number.
          while M[j,l]=0 do   #Search for 1st row item <> 0.
               j:= j+1;
               if m < j then   #End of row: Go to next column.
                    j:= i;
                    l:= l+1;
                    if n < l then return M fi   #end of column and row
               end if
          end do;
          if j<>i then M:= perm(m,j,i).M end if;   #Permute rows j and i
          #Multiply row i with 1/M[i,l], if it's not 0.
          if M[i,l] <> 0 then M:= multiplikation(m,i,1/M[i,l]).M fi;
          #Subtract each row j with row i for M[j,l]-times.
          for j to m do if j<>i and M[j,l]<>0 then M:= addition(m,j,i,-M[j,l]).M fi od;
          l:= l+1   #Increase l by 1; next iteration i increase either.
     end do;
     return M
end proc:

I also restricted the coefficient domain to {float, rational}. This can be relaxed as needed.

@Kitonum It's not my procedure, nor did I claim that it was correct. I only made minor improvements to the OP's main procedure. When I said "here is the corrected reduced," I was refering only to the minor corrections that had already been discussed; and I recommended further testing.

I do claim correctness of the three elementary-matrix procedures.

@JohnS Note, however, that the way that felixp is using it doesn't cause the overwriting of the original argument. In other words, his code doesn't work inplace. His code generates a great many intermediate matrices that need to be garbage collected.

To get inplace operation, every statement of the form

M:= ...

(except for the initialization M:= B!) should be replaced with the equivalent statement of the form

M[..,..]:= ....

(Note that M[..,..] is the literal code; the dots are supposed to be there.)

All the elementary matrices would still need to be garbage collected.

First 426 427 428 429 430 431 432 Last Page 428 of 709