How math function powr() from the frameworks RenderScript works? - renderscript

powr(2.0, 2.0) = 4.0
powr(-2.0, 2.0) = ?
Please tell me.
The documentation is not quite clear.
Thanks

The docs say that the first parameter (base) needs to be between 0.f and 256.f. You can't use it with a negative input.
P.S. RenderScript has been deprecated - https://developer.android.com/guide/topics/renderscript/migrate. You may want to consider this before writing further code using it.

Related

What are similar class for below objects in Harmony OS?

Please help me for similar classes for 1. AppBarLayout, 2.Interpolator(with setInterpolator method), 3. BitmapFactory.decodeResource(res, id), 4. SpannableString, 5. ReplacementSpan in HarmonyOS.
For Interpolator/setInterpolator try using Animator/AnimatorProperty setCurveType(curveType)
By default it is a linear interpolator but you can set other types as well. Please check -
https://developer.harmonyos.com/en/docs/documentation/doc-references/animatorproperty-0000001054439987#ZH-CN_TOPIC_0000001054439987__setCurveType-int-
For BitmapFactory.decodeResource(res, id) : you can use ImageSource and createPixelmap. Something like-
In addition to the BitMapFactory.decodeResource and ImageSource.createPixelmap method classes, No other class can find a similar type in Harmony OS by now.
For details about image decoding, see the following website development guide:
https://developer.harmonyos.com/en/docs/documentation/doc-guides/media-image-decoding-0000000000031770?ha_source=hms1

Does swift have natural log function in it?

I am writing some functions that will solve problems for me and it requires the use of ln (natural log) but I can't seem to find it in swift and I've searched all over the internet but I still can't find the answer. Any help would be appreciated.
let rate : Double = log(finalAmount / initalAmount) / time
return rate
log should be ln.
import Foundation and you'll find log() is implemented for all the real number types. As is log10() and other specialist log functions.

No strictfp in Scala - workarounds?

I searched the web for how to enforce srictfp in Scala but could not find any hint of it. There are some people complaining about it, but real solutions cannot be found. There is a bugtracker entry about it which is almost two years old. As it seems there is no elegant fix for it on the way I'm looking for workarounds.
My current idea is to set the appropiate method flag ACC_STRICT in the generated bytecode by myself somehow but I have no idea what would be the best solution to do so. A Scala Compiler Plugin comes to mind or just hacking flags in a hex editor. Maybe someone faced the same challenge and can tell me his or her solution?
You could add a post-processor in your build process that would add the strictfp modifier to the generated class (i.e. setting the ACC_STRICT flag as you say).
You can implement such a post-processor using Javassist for example. This could look like this:
CtClass clazz = ClassPool.getDefault().makeClass(
new FileInputStream("old/HelloWorld.class"));
CtMethod method = clazz.getDeclaredMethod("testMethod");
method.setModifiers(method.getModifiers() | Modifier.STRICT);
clazz.detach();
clazz.toBytecode(new DataOutputStream(new FileOutputStream(
"new/HelloWorld.class")));
You would then have to find a way to configure which classes/method need to be modified this way.
Scala has a strictfp annotation now:
#strictfp
def f() = …

Wildcard at the Beginning of a searchterm -Lucene

As far as i know lucene(.net) doesn't support the wildcard at the beginning of a searchterm
--> http://lucene.apache.org/java/2_0_0/queryparsersyntax.html
"Note: You cannot use a * or ? symbol as the first character of a search."
for example
*myword
maybe because it's quiet difficult to search "everything" before the searchterm.
Despite that, We are looknig for a way to use the wildcard at the beginning.
Does anyone know if this is possible?
One Thought was asearchterm, bsearchterm, ....z*searchterm
... but that seems a bit random to me.
thanks in advance
Your question is tagged with Lucene.NET so I assume you mean the .NET version rather than the Java version.
Yes, you can have wildcards at the beginning of a search term by via
var queryParser = new QueryParser(LuceneVersion, "content", new StandardAnalyzer(LuceneVersion));
queryParser.SetAllowLeadingWildcard(true);
but you need to be aware of the performance consequences. Find more detailed source code in this blog.
Since Lucene.NET is a port of the Java version, I suspect you could use the same approach for the Java version. I didn't verify this, though.

How to use CTTypesetterSuggestClusterBreak in Core Text

I am having trouble in using CTTypesetterSuggestClusterBreak function of CTTypeSetterRef class. I want to use this method to get closest word boundry near an index. I am having difficult in the implementationof this method, i.e how and where this method must be used.
I have been banging my head over this but with no success yet. If anyone can help me in using this method I would be very greatful.
Thanx in advance
I'm not sure CoreText is appropriate for this task; it sounds like you should investigate CFStringTokenizer instead.