Mosek: suppress printing "MOSEK Version 9.2.3..." - matlab

I am using Mosek in Matlab and I would like to suppress any printing after running an optimisation problem.
I have set param.MSK_IPAR_LOG = 0;. However, I still get the following message printed.
MOSEK Version 9.2.3 (Build date: ...)
Copyright (c) MOSEK ApS, Denmark. WWW: mosek.com
Platform: ...
How can I remove it?

Use echo(0) every time you run mosekopt, for example mosekopt('minimize echo(0)', prob, param) and so on.
https://docs.mosek.com/9.2/toolbox/solver-io.html

A work-around is to count how many characters it displays and then remove those characters.
fprintf(repmat('\b',1,n));
%where n is the number of characters to remove
This doesn't suppress the printing but it removes the printed characters instead.

Related

Is there any way to prevent or detect char(0) from texts?

In some occasions, specially when copy-pasting, we end up having some text fields with a character 0 (nul) at the end of a string.
It doesn't show in any way when you display the data, but you do detect it when you export it.
We've tried to (at least) detect it by using the "Position" function.
However Position(text_field, char(0), 1, 1) won't find this char (it does return 0, even if the character is there).
I guess this is some kind of bug from FileMaker, but I'd like to know if anyone has found a way to circumvent it...
More info and a database sample at: https://community.claris.com/en/s/question/0D53w00005wrUMMCA2/character-0-0x0-in-text-fields
Unfortunately, the result of Char(0) is an empty string, not the expected control character.
You can generate the null character in a number of ways:
HexDecode ( "00" )
Base64Decode ( "AA==" )
ExecuteSQL ( "SELECT DISTINCT CHR(0) FROM SomeTable" ; "" ; "" )
or paste it into a global field and get it from there.
Once you have the character, it's easy to detect it or just substitute it out.
You may want to bypass the entire issue by allowing only printable characters - see, for example: https://www.briandunning.com/cf/1291
I run into this problem quite frequently when users try to copy-paste text from office programs into FileMaker fields on windows (my guess is that FileMaker for some reason can't handle Microsoft Office line endings properly).
The most efficient solution I found is to use auto enter calculation or script with Filter() function, in order to remove any unwanted characters.
Alterntively if you have access to plug-ins you can try using the MBS ("Text.RemoveControlCharacters") function from Monkeybread FileMaker plug-in which is uspposed to remove all characters with code 32 or lower.

Chinese Characters corrupted when using Protractor sendKeys method

Are there any known issues with using Protractor to enter SMP characters?
When I use the sendKeys() method, the result is two corrupted entries.
For example, when attempting to enter '𠀀' via the sendKeys('𠀀') the result in the UI is enter image description here.
And if I print out the sendKeys('𠀀'.length), the result is 2. It seems like the character is being interpretted as two individual characters.
Is this a known issue with Protractor?
Much thanks in advance,
M

Two digits after the decimal point in a real number in Pascal

So for an example i have a real number let's say 17.4578 but i want to display it in pascal with only two digits after the point so it's 17.45.
What do i write in my program?
Write(17.4578:0:2)
Will display number 17.46
Generally, arguments look like this → Value : field_width : decimal_field_width
For more info click here
This would work. However, if this is the last line of code always remember a readln at the end.
Writeln(17.4578:0:2)
This would lead to 17.46 because it rounds up as it is followed by a 7.
Hope this helps
Use :0:2 at the end of Real number:
writeln(17.4578:0:2)

How to select a region with a leading \$, and surround it with a yasnippet

Could anyone please suggest a method to surround a region that contains a leading \$ and surround it with a snippet. In latex-mode, I am frequently underlining or double-underlining monies due and the yasnippet being used removes the backslash. I'd like to be able to use the same snippet for all situations -- with or without a leading \$.
# -*- mode: snippet -*-
# contributor: lawlist
# key: underline_selected
# group: font
# name: underline_selected
# binding: C-I u s
# --
\uline{`yas/selected-text`}
There are few problems that cause the behavior described by the original poster, who uses a custom modified version of tex-mode.el, not AUCTeX.
First, the function yas--snippet-parse-create contains, among other codes, the following functions that do not play well with LaTeX escaped dollar signs:
(yas--protect-escapes nil `(?\\ ?` ?'))
(yas--protect-escapes)
(yas--restore-escapes)
(yas--delete-regions ys--dollar-regions)
Second, the variable yas--simple-mirror-regexp catches dollar amounts, in addition to the standard yasnippet fields such as $1. When the above-mentioned (yas--delete-regions yas--dollar-regions) is called by yas--snippet-parse-create, the result is an erroneous deletion. The author of this answer has modified the regexp to exclude a dollar-sign with a preceding backslash:
(setq yas--simple-mirror-regexp "[^\\]$\\([0-9]+\\)")
The author of this answer does not presently have a fix for yas--protect-escapes and yas--restore-escapes, and has merely commented them out in the meantime. [This would obviously be problematic for anyone doing programming, but appears to be sufficient for merely writing LaTeX documents.] An issue has been opened on Github and the author of this answer will update this thread if a solution is found there.

Why would Perl's printf output the format specifier rather than the formatted number?

I'm trying to debug a problem on a remote user's site. We've narrowed it down to a problem with formatted output in Perl. The user swears up and down that
perl -e 'printf "Number: %lG\n", 0.1'
prints
Number: %lG
not
Number: 0.1
The user reports that their Perl is version 5.8. The oldest version I have around is 5.8.1, and it seems to behave correctly.
Any guesses? Misconfiguration? Module conflicts?
Quoting from the sprintf documentation:
Returns a string formatted by the usual printf conventions of the C library
function sprintf. See below for more details and see sprintf(3) or
printf(3) on your system for an explanation of the general principles.
IOW, like with many built-ins, Perl just thinly wraps a function, and it's
platform dependent.
Perl's sprintf permits the following universally-known conversions:
%l is not part of it. My guess is that the remote user is not using GNU. He can find out exactly what is supported by his unwashed Unix by typing man 3 sprintf or man 3 printf.
It should only do that if it doesn't recognise the format specifier. For example:
pax> perl -e 'printf "Number: %q\n", 0.1'
Number: %q
I think you're going to have to go on site to figure this one out although you may want to first get them to cut and paste the text and a screen dump from, for example, HyperSnap demo, into an email so you can check it carefully. I only suggest that one since we use it internally and it has a free trial. You can use any decent screen capture program you like.
I originally thought that they may be typing in 1G (wun jee) instead of lG (ell jee) but the former still works.
I do notice the IG (eye jee) will print out the text rather than the number but, unless they're using a particularly bad font, that should be a recognisable difference.
BTW, I only have 5.10 to work with so it may be a version problem. It's hard to imagine, however, that there'd be a major difference between 5.8 and 5.8.1.
It looks like it was a Perl build configuration issue. The Perl build supports a `d_longdbl` option, which indicates whether long doubles are allowed or not. You can test whether it is set on your machine with:
perl -V:d_longdbl
More info at perldoc sprintf.
Thanks for your input everybody.
Edit:
Nope, that wasn't it either. Close inspection of the sprintf documentation revealed that the modifiers for a long double are q, ll, and L, NOT l. l is a valid modifer for integer types. D'oh.
It looks like most installations of perl will silently ignore the l, and parse the rest of the modifier correctly. Except on our user's site. ☹ Anyway, the problem was fixed by using a valid modifier for a long double.
FYI, I played with the same format specifiers in the C printf.
printf("The number is %lG\n", 0.001);
printf("The number is %LG\n", 0.001);
The first call “worked”, printing out 0.001, but the second call printed out a garbage value until I properly specified the type of the numeric literal:
printf("The number is %LG\n", 0.001L);
Apparently the C printf is silently ignoring the improper l modifier. This makes me suspect that most Perl installations ignore it too.