Apply numerical filters with DM script functions - imagefilter

Are there DM script functions that will allow direct access to the numerical filters found under the "Spectrum/Numerical Filters" menu such as:
Savitzky-Golay
and the others: Smooth (low-pass), Structure (high-pass), First
derivative, Log derivative, Log-log derivative, and Second Derivative

There are such commands, but these are not officially documented/supported and may be used with caution. They may not exist/work in all versions of the software.
RealImage Smooth_Spectrum( RealImage, Number )
RealImage Structure_Spectrum( RealImage, Number )
RealImage FDeriv_Spectrum( RealImage, Number, Number, Number )
RealImage SDeriv_Spectrum( RealImage, Number, Number, Number, Number )
RealImage LogDeriv_Spectrum( RealImage, Number, Number, Number )
RealImage LogLogDeriv_Spectrum( RealImage, Number, Number, Number, Number, Number )
RealImage SavitzkyGolay_Filter( RealImage, Number, Number, Number, Number )

Related

Microsoft SEAL : Required negative values as a result after subtraction of two PolyCRT composed ciphertexts

Suppose I have two vectors x = [1,2,3,4] and y = [5,1,2,6].
I composed and encrypted the two array using PolyCRTBuilder ( Ciphertextx and Ciphertexty ) .
If I subtract the two ciphertexts ( Ciphertextx MINUS Ciphertexty ), I should get Result = [-4, 1, 1, -2] but after the homomorphic subtraction I am getting ResultDecrypted = [40957, 1, 1, 40959] .
I understood that because the plaintext is only defined modulo plain_modulus, we got that result. But i want the resultant negative values to be used for the next computation how can i assign the resultant negative values to a vector and use the same for the further computations
You are using a pretty old version of SEAL if it still has PolyCRTBuilder; in newer versions of the library this has been renamed to BatchEncoder and it supports encoding to/from std::vector<std::int64_t> which, I believe, is what you want.

How do you truncate or round numbers by units NOT decimals?

I have dates and times in number format of YYYYMMDDHHMMSS. As a group by for a sum, I want to have the ability to group by:
YYYYMM
YYYYMMDD
YYYYMMDDHH
I have previously used this below, but it converts it into a string, which isn't great:
"sum_by_date": { $substrBytes: [ "$_id.transaction_date", 0, 7
] }
What I want to achieve from 20181217134218 for by month is either:
201812 or 20181200000000 and kept as a number format.
Thanks, Matt
Use integer division to truncate the number. In Ruby:
(20181217134218 / 100000000) * 100000000 # = 20181200000000

Is real number natural?

I have 2 real numbers ( e.g. a , b). Is there any way to know whether is their division's result natural number?
I have tried
a mod b {to check if the result is 0}
but "mod" doesn't work for real numbers.
Also
a/b-trunc(a/b) {but sometimes the answer isn't 0}
I'm beginner, please, whether is there any other way, let me know.
Using Frac could be one idea as #Sertac mentions. But since binary floating point does not represent all real numbers, there could be cases where the fraction could end up close to zero (or one for that matter) as well.
Here is a simple routine that avoids testing for both close to one or zero:
function IsNaturalNumber( value : Double) : Boolean;
const
epsilon : Double = 1E-12;
begin
IsNaturalNumber := Abs(value - Round(value)) < epsilon;
end;
var
A,B : Double;
begin
A := 3.3;
B := 1.1;
WriteLn(IsNaturalNumber(A/B)); // Writes TRUE
end.
The function tests if the absolute difference between the value and the value rounded to nearest integer is smaller than a reasonable limit.
Note that there is no absolute certainty. That would require using a decimal floating point arithmetic library.
I will leave it up to the interested reader to implement the exclusion of integer numbers that is outside the range of the natural numbers, whether that is all negative numbers including zero or not.
If the values to test are larger than the upper range of the Round() function, use an equivalent floating point function. In Delphi that is Math.RoundTo(value,0).

Currency amount must be non-negative number, may optionally contain exactly 2 decimal places separated by '.'

When I use the vue-paypal-check:
<PayPal amount="amount"
currency="USD"
:client="credentials"
env="sandbox"
>
</Paypal>
...
computed: {
amount() {
var total_price = Number(this.product_physical_session_storage_from_before.total_price_local)
var abs_total_price = Math.abs(total_price.toFixed(2))
return abs_total_price // there is Number `120.00`
}
},
I get bellow error:
{"name":"VALIDATION_ERROR","details":[{"field":"transactions[0].amount.total","issue":"Currency amount must be non-negative number, may optionally contain exactly 2 decimal places separated by '.', optional thousands separator ',', limited to 7 digits before the decimal point"}],"message":"Invalid request - see details","information_link":"https://developer.paypal.com/webapps/developer/docs/api/#VALIDATION_ERROR","debug_id":"efa7b058ad30e"}
Afterwards I found the issue, I was follow the GitHub steps:
<PayPal
amount="10.00"
currency="USD"
:client="credentials">
</PayPal>
the 10.00 is the given number, I'm passing a variable, I should use the
<PayPal
:amount="amount"
currency="USD"
:client="credentials">
</PayPal>
Then I solved my problem.

Algorithm to convert integer (represented as an array) with base n to integer with base m

I have a, very long, integer. The integer is represented by a array of unsigned chars.
Example: the integer 1234 with base 10 is represented in the array as [4,3,2,1], [2,2,3,2] (base 8) and [2,13,4] (base 16)
Now I want to convert my integer with base n to another integer with base m. In my persued for a answer I came accross Wallar's algorithm, originally from here.
from math import *
def baseExpansion(n,c,b):
j = 0
base10 = sum([pow(c,len(n)-k-1)*n[k] for k in range(0,len(n))])
while floor(base10/pow(b,j)) != 0: j = j+1
return [floor(base10/pow(b,j-p)) % b for p in range(1,j+1)]
At first I thought this was my answer but unfortunately it is not. The problem I have is that the algorithm computes the sum. In my case this is a problem because the variable base10 is of type unsigned integer of 32 bits. Therefore when my integer, represented as a array, has more then 10 digits it can not convert the number anymore. Anyone has a solution?
Here's the school-book algorithm for doing what you're trying. You start with a representation for zero and call it a running total. Then, for each digit of the number to be converted, starting with the most significant and going to the least significant, 1) multiply the running total by the base of the source number and 2) add the digit to the running total. Now all you need is algorithms to do the multiplication and addition (and you can actually do both at once). Here's how to do that: 1) set the current digit to a variable, call it "carry", 2) for each digit in your new number, starting with the least significant and going to the most significant: 2a) set carry to the current digit in the new number times the output base plus carry, 2b) set the current digit to carry mod the output base, 2c) set carry to carry divided by the output base. And that should do it. There is an implementation of what you are trying to do somewhere here: http://www.cis.ksu.edu/~howell/calculator/comparison.html