index
int64
repo_id
string
file_path
string
content
string
0
java-sources/ai/sahha/sahha-android/1.2.0/sdk/sahha/android/domain/use_case
java-sources/ai/sahha/sahha-android/1.2.0/sdk/sahha/android/domain/use_case/post/PostSleepDataUseCase_Factory.java
package sdk.sahha.android.domain.use_case.post; import dagger.internal.DaggerGenerated; import dagger.internal.Factory; import dagger.internal.QualifierMetadata; import dagger.internal.ScopeMetadata; import javax.annotation.processing.Generated; import javax.inject.Provider; import sdk.sahha.android.domain.repository.SensorRepo; import sdk.sahha.android.domain.repository.SleepRepo; import sdk.sahha.android.domain.use_case.metadata.AddMetadata; @ScopeMetadata @QualifierMetadata @DaggerGenerated @Generated( value = "dagger.internal.codegen.ComponentProcessor", comments = "https://dagger.dev" ) @SuppressWarnings({ "unchecked", "rawtypes", "KotlinInternal", "KotlinInternalInJava" }) public final class PostSleepDataUseCase_Factory implements Factory<PostSleepDataUseCase> { private final Provider<SensorRepo> sensorRepoProvider; private final Provider<SleepRepo> sleepRepoProvider; private final Provider<AddMetadata> addMetadataProvider; public PostSleepDataUseCase_Factory(Provider<SensorRepo> sensorRepoProvider, Provider<SleepRepo> sleepRepoProvider, Provider<AddMetadata> addMetadataProvider) { this.sensorRepoProvider = sensorRepoProvider; this.sleepRepoProvider = sleepRepoProvider; this.addMetadataProvider = addMetadataProvider; } @Override public PostSleepDataUseCase get() { return newInstance(sensorRepoProvider.get(), sleepRepoProvider.get(), addMetadataProvider.get()); } public static PostSleepDataUseCase_Factory create(Provider<SensorRepo> sensorRepoProvider, Provider<SleepRepo> sleepRepoProvider, Provider<AddMetadata> addMetadataProvider) { return new PostSleepDataUseCase_Factory(sensorRepoProvider, sleepRepoProvider, addMetadataProvider); } public static PostSleepDataUseCase newInstance(SensorRepo sensorRepo, SleepRepo sleepRepo, AddMetadata addMetadata) { return new PostSleepDataUseCase(sensorRepo, sleepRepo, addMetadata); } }
0
java-sources/ai/sahha/sahha-android/1.2.0/sdk/sahha/android/domain/use_case
java-sources/ai/sahha/sahha-android/1.2.0/sdk/sahha/android/domain/use_case/post/PostStepDataUseCase_Factory.java
package sdk.sahha.android.domain.use_case.post; import dagger.internal.DaggerGenerated; import dagger.internal.Factory; import dagger.internal.QualifierMetadata; import dagger.internal.ScopeMetadata; import javax.annotation.processing.Generated; import javax.inject.Provider; import sdk.sahha.android.domain.repository.SensorRepo; @ScopeMetadata @QualifierMetadata @DaggerGenerated @Generated( value = "dagger.internal.codegen.ComponentProcessor", comments = "https://dagger.dev" ) @SuppressWarnings({ "unchecked", "rawtypes", "KotlinInternal", "KotlinInternalInJava" }) public final class PostStepDataUseCase_Factory implements Factory<PostStepDataUseCase> { private final Provider<SensorRepo> repositoryProvider; public PostStepDataUseCase_Factory(Provider<SensorRepo> repositoryProvider) { this.repositoryProvider = repositoryProvider; } @Override public PostStepDataUseCase get() { return newInstance(repositoryProvider.get()); } public static PostStepDataUseCase_Factory create(Provider<SensorRepo> repositoryProvider) { return new PostStepDataUseCase_Factory(repositoryProvider); } public static PostStepDataUseCase newInstance(SensorRepo repository) { return new PostStepDataUseCase(repository); } }
0
java-sources/ai/sahha/sahha-android/1.2.0/sdk/sahha/android/domain/use_case
java-sources/ai/sahha/sahha-android/1.2.0/sdk/sahha/android/domain/use_case/post/StartHealthConnectBackgroundTasksUseCase_Factory.java
package sdk.sahha.android.domain.use_case.post; import dagger.internal.DaggerGenerated; import dagger.internal.Factory; import dagger.internal.QualifierMetadata; import dagger.internal.ScopeMetadata; import javax.annotation.processing.Generated; import javax.inject.Provider; import sdk.sahha.android.domain.repository.HealthConnectRepo; @ScopeMetadata @QualifierMetadata @DaggerGenerated @Generated( value = "dagger.internal.codegen.ComponentProcessor", comments = "https://dagger.dev" ) @SuppressWarnings({ "unchecked", "rawtypes", "KotlinInternal", "KotlinInternalInJava" }) public final class StartHealthConnectBackgroundTasksUseCase_Factory implements Factory<StartHealthConnectBackgroundTasksUseCase> { private final Provider<HealthConnectRepo> repositoryProvider; public StartHealthConnectBackgroundTasksUseCase_Factory( Provider<HealthConnectRepo> repositoryProvider) { this.repositoryProvider = repositoryProvider; } @Override public StartHealthConnectBackgroundTasksUseCase get() { return newInstance(repositoryProvider.get()); } public static StartHealthConnectBackgroundTasksUseCase_Factory create( Provider<HealthConnectRepo> repositoryProvider) { return new StartHealthConnectBackgroundTasksUseCase_Factory(repositoryProvider); } public static StartHealthConnectBackgroundTasksUseCase newInstance(HealthConnectRepo repository) { return new StartHealthConnectBackgroundTasksUseCase(repository); } }
0
java-sources/ai/sahha/sahha-android/1.2.0/sdk/sahha/android/domain/use_case
java-sources/ai/sahha/sahha-android/1.2.0/sdk/sahha/android/domain/use_case/post/StartPostWorkersUseCase_Factory.java
package sdk.sahha.android.domain.use_case.post; import dagger.internal.DaggerGenerated; import dagger.internal.Factory; import dagger.internal.QualifierMetadata; import dagger.internal.ScopeMetadata; import javax.annotation.processing.Generated; import javax.inject.Provider; import kotlinx.coroutines.CoroutineScope; import sdk.sahha.android.domain.manager.PermissionManager; import sdk.sahha.android.domain.repository.SahhaConfigRepo; import sdk.sahha.android.domain.repository.SensorRepo; @ScopeMetadata @QualifierMetadata("sdk.sahha.android.di.IoScope") @DaggerGenerated @Generated( value = "dagger.internal.codegen.ComponentProcessor", comments = "https://dagger.dev" ) @SuppressWarnings({ "unchecked", "rawtypes", "KotlinInternal", "KotlinInternalInJava" }) public final class StartPostWorkersUseCase_Factory implements Factory<StartPostWorkersUseCase> { private final Provider<CoroutineScope> ioScopeProvider; private final Provider<SensorRepo> sensorRepoProvider; private final Provider<SahhaConfigRepo> configRepoProvider; private final Provider<PermissionManager> permissionManagerProvider; public StartPostWorkersUseCase_Factory(Provider<CoroutineScope> ioScopeProvider, Provider<SensorRepo> sensorRepoProvider, Provider<SahhaConfigRepo> configRepoProvider, Provider<PermissionManager> permissionManagerProvider) { this.ioScopeProvider = ioScopeProvider; this.sensorRepoProvider = sensorRepoProvider; this.configRepoProvider = configRepoProvider; this.permissionManagerProvider = permissionManagerProvider; } @Override public StartPostWorkersUseCase get() { return newInstance(ioScopeProvider.get(), sensorRepoProvider.get(), configRepoProvider.get(), permissionManagerProvider.get()); } public static StartPostWorkersUseCase_Factory create(Provider<CoroutineScope> ioScopeProvider, Provider<SensorRepo> sensorRepoProvider, Provider<SahhaConfigRepo> configRepoProvider, Provider<PermissionManager> permissionManagerProvider) { return new StartPostWorkersUseCase_Factory(ioScopeProvider, sensorRepoProvider, configRepoProvider, permissionManagerProvider); } public static StartPostWorkersUseCase newInstance(CoroutineScope ioScope, SensorRepo sensorRepo, SahhaConfigRepo configRepo, PermissionManager permissionManager) { return new StartPostWorkersUseCase(ioScope, sensorRepo, configRepo, permissionManager); } }
0
java-sources/ai/sahha/sahha-android/1.2.0/sdk/sahha/android/framework
java-sources/ai/sahha/sahha-android/1.2.0/sdk/sahha/android/framework/activity/SahhaPermissionActivity_Factory.java
package sdk.sahha.android.framework.activity; import dagger.internal.DaggerGenerated; import dagger.internal.Factory; import dagger.internal.QualifierMetadata; import dagger.internal.ScopeMetadata; import javax.annotation.processing.Generated; import javax.inject.Provider; import sdk.sahha.android.domain.model.categories.PermissionHandler; @ScopeMetadata @QualifierMetadata @DaggerGenerated @Generated( value = "dagger.internal.codegen.ComponentProcessor", comments = "https://dagger.dev" ) @SuppressWarnings({ "unchecked", "rawtypes", "KotlinInternal", "KotlinInternalInJava" }) public final class SahhaPermissionActivity_Factory implements Factory<SahhaPermissionActivity> { private final Provider<PermissionHandler> permissionHandlerProvider; public SahhaPermissionActivity_Factory(Provider<PermissionHandler> permissionHandlerProvider) { this.permissionHandlerProvider = permissionHandlerProvider; } @Override public SahhaPermissionActivity get() { return newInstance(permissionHandlerProvider.get()); } public static SahhaPermissionActivity_Factory create( Provider<PermissionHandler> permissionHandlerProvider) { return new SahhaPermissionActivity_Factory(permissionHandlerProvider); } public static SahhaPermissionActivity newInstance(PermissionHandler permissionHandler) { return new SahhaPermissionActivity(permissionHandler); } }
0
java-sources/ai/sahha/sahha-android/1.2.0/sdk/sahha/android/framework
java-sources/ai/sahha/sahha-android/1.2.0/sdk/sahha/android/framework/manager/AndroidConnectionStateManager_Factory.java
package sdk.sahha.android.framework.manager; import android.content.Context; import dagger.internal.DaggerGenerated; import dagger.internal.Factory; import dagger.internal.QualifierMetadata; import dagger.internal.ScopeMetadata; import javax.annotation.processing.Generated; import javax.inject.Provider; @ScopeMetadata @QualifierMetadata @DaggerGenerated @Generated( value = "dagger.internal.codegen.ComponentProcessor", comments = "https://dagger.dev" ) @SuppressWarnings({ "unchecked", "rawtypes", "KotlinInternal", "KotlinInternalInJava" }) public final class AndroidConnectionStateManager_Factory implements Factory<AndroidConnectionStateManager> { private final Provider<Context> contextProvider; public AndroidConnectionStateManager_Factory(Provider<Context> contextProvider) { this.contextProvider = contextProvider; } @Override public AndroidConnectionStateManager get() { return newInstance(contextProvider.get()); } public static AndroidConnectionStateManager_Factory create(Provider<Context> contextProvider) { return new AndroidConnectionStateManager_Factory(contextProvider); } public static AndroidConnectionStateManager newInstance(Context context) { return new AndroidConnectionStateManager(context); } }
0
java-sources/ai/sahha/sahha-android/1.2.0/sdk/sahha/android/framework
java-sources/ai/sahha/sahha-android/1.2.0/sdk/sahha/android/framework/observer/HostAppLifecycleObserver_Factory.java
package sdk.sahha.android.framework.observer; import android.content.Context; import dagger.internal.DaggerGenerated; import dagger.internal.Factory; import dagger.internal.QualifierMetadata; import dagger.internal.ScopeMetadata; import javax.annotation.processing.Generated; import javax.inject.Provider; import kotlinx.coroutines.CoroutineScope; import sdk.sahha.android.domain.interaction.PermissionInteractionManager; import sdk.sahha.android.domain.model.processor.AppEventProcessor; import sdk.sahha.android.domain.repository.BatchedDataRepo; @ScopeMetadata @QualifierMetadata("sdk.sahha.android.di.IoScope") @DaggerGenerated @Generated( value = "dagger.internal.codegen.ComponentProcessor", comments = "https://dagger.dev" ) @SuppressWarnings({ "unchecked", "rawtypes", "KotlinInternal", "KotlinInternalInJava" }) public final class HostAppLifecycleObserver_Factory implements Factory<HostAppLifecycleObserver> { private final Provider<Context> contextProvider; private final Provider<AppEventProcessor> processorProvider; private final Provider<BatchedDataRepo> repositoryProvider; private final Provider<PermissionInteractionManager> permissionInteractionManagerProvider; private final Provider<CoroutineScope> scopeProvider; public HostAppLifecycleObserver_Factory(Provider<Context> contextProvider, Provider<AppEventProcessor> processorProvider, Provider<BatchedDataRepo> repositoryProvider, Provider<PermissionInteractionManager> permissionInteractionManagerProvider, Provider<CoroutineScope> scopeProvider) { this.contextProvider = contextProvider; this.processorProvider = processorProvider; this.repositoryProvider = repositoryProvider; this.permissionInteractionManagerProvider = permissionInteractionManagerProvider; this.scopeProvider = scopeProvider; } @Override public HostAppLifecycleObserver get() { return newInstance(contextProvider.get(), processorProvider.get(), repositoryProvider.get(), permissionInteractionManagerProvider.get(), scopeProvider.get()); } public static HostAppLifecycleObserver_Factory create(Provider<Context> contextProvider, Provider<AppEventProcessor> processorProvider, Provider<BatchedDataRepo> repositoryProvider, Provider<PermissionInteractionManager> permissionInteractionManagerProvider, Provider<CoroutineScope> scopeProvider) { return new HostAppLifecycleObserver_Factory(contextProvider, processorProvider, repositoryProvider, permissionInteractionManagerProvider, scopeProvider); } public static HostAppLifecycleObserver newInstance(Context context, AppEventProcessor processor, BatchedDataRepo repository, PermissionInteractionManager permissionInteractionManager, CoroutineScope scope) { return new HostAppLifecycleObserver(context, processor, repository, permissionInteractionManager, scope); } }
0
java-sources/ai/sahha/sahha-android/1.2.0/sdk/sahha/android/framework
java-sources/ai/sahha/sahha-android/1.2.0/sdk/sahha/android/framework/processor/AppEventProcessorImpl_Factory.java
package sdk.sahha.android.framework.processor; import android.content.Context; import dagger.internal.DaggerGenerated; import dagger.internal.Factory; import dagger.internal.QualifierMetadata; import dagger.internal.ScopeMetadata; import javax.annotation.processing.Generated; import javax.inject.Provider; import sdk.sahha.android.domain.manager.IdManager; import sdk.sahha.android.domain.mapper.HealthConnectConstantsMapper; @ScopeMetadata @QualifierMetadata @DaggerGenerated @Generated( value = "dagger.internal.codegen.ComponentProcessor", comments = "https://dagger.dev" ) @SuppressWarnings({ "unchecked", "rawtypes", "KotlinInternal", "KotlinInternalInJava" }) public final class AppEventProcessorImpl_Factory implements Factory<AppEventProcessorImpl> { private final Provider<Context> contextProvider; private final Provider<HealthConnectConstantsMapper> mapperProvider; private final Provider<IdManager> managerProvider; public AppEventProcessorImpl_Factory(Provider<Context> contextProvider, Provider<HealthConnectConstantsMapper> mapperProvider, Provider<IdManager> managerProvider) { this.contextProvider = contextProvider; this.mapperProvider = mapperProvider; this.managerProvider = managerProvider; } @Override public AppEventProcessorImpl get() { return newInstance(contextProvider.get(), mapperProvider.get(), managerProvider.get()); } public static AppEventProcessorImpl_Factory create(Provider<Context> contextProvider, Provider<HealthConnectConstantsMapper> mapperProvider, Provider<IdManager> managerProvider) { return new AppEventProcessorImpl_Factory(contextProvider, mapperProvider, managerProvider); } public static AppEventProcessorImpl newInstance(Context context, HealthConnectConstantsMapper mapper, IdManager manager) { return new AppEventProcessorImpl(context, mapper, manager); } }
0
java-sources/ai/sahha/sahha-android/1.2.0/sdk/sahha/android/framework
java-sources/ai/sahha/sahha-android/1.2.0/sdk/sahha/android/framework/runnable/DataBatcherRunnable_Factory.java
package sdk.sahha.android.framework.runnable; import android.content.Context; import dagger.internal.DaggerGenerated; import dagger.internal.Factory; import dagger.internal.QualifierMetadata; import dagger.internal.ScopeMetadata; import javax.annotation.processing.Generated; import javax.inject.Provider; import sdk.sahha.android.domain.interaction.SensorInteractionManager; import sdk.sahha.android.domain.manager.PermissionManager; import sdk.sahha.android.domain.repository.SahhaConfigRepo; @ScopeMetadata @QualifierMetadata @DaggerGenerated @Generated( value = "dagger.internal.codegen.ComponentProcessor", comments = "https://dagger.dev" ) @SuppressWarnings({ "unchecked", "rawtypes", "KotlinInternal", "KotlinInternalInJava" }) public final class DataBatcherRunnable_Factory implements Factory<DataBatcherRunnable> { private final Provider<Context> contextProvider; private final Provider<PermissionManager> permissionManagerProvider; private final Provider<SensorInteractionManager> sensorManagerProvider; private final Provider<SahhaConfigRepo> configRepositoryProvider; public DataBatcherRunnable_Factory(Provider<Context> contextProvider, Provider<PermissionManager> permissionManagerProvider, Provider<SensorInteractionManager> sensorManagerProvider, Provider<SahhaConfigRepo> configRepositoryProvider) { this.contextProvider = contextProvider; this.permissionManagerProvider = permissionManagerProvider; this.sensorManagerProvider = sensorManagerProvider; this.configRepositoryProvider = configRepositoryProvider; } @Override public DataBatcherRunnable get() { return newInstance(contextProvider.get(), permissionManagerProvider.get(), sensorManagerProvider.get(), configRepositoryProvider.get()); } public static DataBatcherRunnable_Factory create(Provider<Context> contextProvider, Provider<PermissionManager> permissionManagerProvider, Provider<SensorInteractionManager> sensorManagerProvider, Provider<SahhaConfigRepo> configRepositoryProvider) { return new DataBatcherRunnable_Factory(contextProvider, permissionManagerProvider, sensorManagerProvider, configRepositoryProvider); } public static DataBatcherRunnable newInstance(Context context, PermissionManager permissionManager, SensorInteractionManager sensorManager, SahhaConfigRepo configRepository) { return new DataBatcherRunnable(context, permissionManager, sensorManager, configRepository); } }
0
java-sources/ai/salmonbrain/experiment-sdk/0.0.1/ai/salmonbrain/client
java-sources/ai/salmonbrain/experiment-sdk/0.0.1/ai/salmonbrain/client/hash/HashFunction.java
package ai.salmonbrain.client.hash; public interface HashFunction<T> { long getHash(T key, String salt); }
0
java-sources/ai/salmonbrain/experiment-sdk/0.0.1/ai/salmonbrain/client
java-sources/ai/salmonbrain/experiment-sdk/0.0.1/ai/salmonbrain/client/hash/HashFunctions.java
package ai.salmonbrain.client.hash; public class HashFunctions { private static final int DEFAULT_STRING_SEED = 99999989; /** * The MurmurHash3 algorithm was created by Austin Appleby and placed in the private domain. * This java port was authored by Yonik Seeley and also placed into the private domain. * It has been modified by Konstantin Sobolev and, you guessed it, also placed in the private domain. * The author hereby disclaims copyright to this source code. * <p> * This produces exactly the same hash values as the final C++ * version of MurmurHash3 and is thus suitable for producing the same hash values across * platforms. * <p> * The 32 bit x86 version of this hash should be the fastest variant for relatively short keys like ids. * murmurhash3_x64_128 is a good choice for longer strings or if you need more than 32 bits of hash. * <p> * Note - The x86 and x64 versions do _not_ produce the same results, as the * algorithms are optimized for their respective platforms. */ private static final class MurmurHash3 { static final long c1 = 0x87c37b91114253d5L; static final long c2 = 0x4cf5ad432745937fL; /** * 128 bits of state */ private static final class HashCode128 { /** * First part of the hash, use it if you only need 64-bit hash */ private long val1; /** * Second part of the hash */ private long val2; private HashCode128(long v1, long v2) { val1 = v1; val2 = v2; } private HashCode128() { this(0, 0); } private byte[] getBytes() { return new byte[]{(byte) val1, (byte) (val1 >>> 8), (byte) (val1 >>> 16), (byte) (val1 >>> 24), (byte) (val1 >>> 32), (byte) (val1 >>> 40), (byte) (val1 >>> 48), (byte) (val1 >>> 56), (byte) val2, (byte) (val2 >>> 8), (byte) (val2 >>> 16), (byte) (val2 >>> 24), (byte) (val2 >>> 32), (byte) (val2 >>> 40), (byte) (val2 >>> 48), (byte) (val2 >>> 56),}; } @Override public boolean equals(final Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; final HashCode128 pair = (HashCode128) o; return val1 == pair.val1 && val2 == pair.val2; } @Override public int hashCode() { return (int) (val1 * 31 + val2); } public int toInt() { return (int) val1; } public long toLong() { return val1; } @Override public String toString() { byte[] bytes = getBytes(); StringBuilder sb = new StringBuilder(2 * bytes.length); for (byte b : bytes) { sb.append(hexDigits[(b >> 4) & 0xf]).append(hexDigits[b & 0xf]); } return sb.toString(); } public static MurmurHash3.HashCode128 fromBytes(byte[] bytes) { return new HashCode128(getLongLittleEndian(bytes, 0), getLongLittleEndian(bytes, 8)); } private static final char[] hexDigits = "0123456789abcdef".toCharArray(); } private static int fmix32(int h) { h ^= h >>> 16; h *= 0x85ebca6b; h ^= h >>> 13; h *= 0xc2b2ae35; h ^= h >>> 16; return h; } private static long fmix64(long k) { k ^= k >>> 33; k *= 0xff51afd7ed558ccdL; k ^= k >>> 33; k *= 0xc4ceb9fe1a85ec53L; k ^= k >>> 33; return k; } /** * Gets a long from a byte buffer in little endian byte order. */ private static long getLongLittleEndian(byte[] buf, int offset) { return ((long) buf[offset + 7] << 56) // no mask needed | ((buf[offset + 6] & 0xffL) << 48) | ((buf[offset + 5] & 0xffL) << 40) | ((buf[offset + 4] & 0xffL) << 32) | ((buf[offset + 3] & 0xffL) << 24) | ((buf[offset + 2] & 0xffL) << 16) | ((buf[offset + 1] & 0xffL) << 8) | ((buf[offset] & 0xffL)); // no shift needed } /** * Returns the MurmurHash3_x86_32 hash. */ private static int murmurhash3_x86_32(byte[] data, int offset, int len, int seed) { final int c1 = 0xcc9e2d51; final int c2 = 0x1b873593; int h1 = seed; int roundedEnd = offset + (len & 0xfffffffc); // round down to 4 byte block for (int i = offset; i < roundedEnd; i += 4) { // little endian load order int k1 = (data[i] & 0xff) | ((data[i + 1] & 0xff) << 8) | ((data[i + 2] & 0xff) << 16) | (data[i + 3] << 24); k1 *= c1; k1 = (k1 << 15) | (k1 >>> 17); // ROTL32(k1,15); k1 *= c2; h1 ^= k1; h1 = (h1 << 13) | (h1 >>> 19); // ROTL32(h1,13); h1 = h1 * 5 + 0xe6546b64; } // tail int k1 = 0; switch (len & 0x03) { case 3: k1 = (data[roundedEnd + 2] & 0xff) << 16; // fallthrough case 2: k1 |= (data[roundedEnd + 1] & 0xff) << 8; // fallthrough case 1: k1 |= (data[roundedEnd] & 0xff); k1 *= c1; k1 = (k1 << 15) | (k1 >>> 17); // ROTL32(k1,15); k1 *= c2; h1 ^= k1; } // finalization h1 ^= len; // fmix(h1); h1 ^= h1 >>> 16; h1 *= 0x85ebca6b; h1 ^= h1 >>> 13; h1 *= 0xc2b2ae35; h1 ^= h1 >>> 16; return h1; } /** * Returns the MurmurHash3_x86_32 hash of the UTF-8 bytes of the String without actually encoding * the string to a temporary buffer. This is more than 2x faster than hashing the result * of String.getBytes(). */ private static int murmurhash3_x86_32(CharSequence data, int offset, int len, int seed) { final int c1 = 0xcc9e2d51; final int c2 = 0x1b873593; int h1 = seed; int pos = offset; int end = offset + len; int k1 = 0; int k2 = 0; int shift = 0; int bits = 0; int nBytes = 0; // length in UTF8 bytes while (pos < end) { int code = data.charAt(pos++); if (code < 0x80) { k2 = code; bits = 8; /*** // optimized ascii implementation (currently slower!!! code size?) if (shift == 24) { k1 = k1 | (code << 24); k1 *= c1; k1 = (k1 << 15) | (k1 >>> 17); // ROTL32(k1,15); k1 *= c2; h1 ^= k1; h1 = (h1 << 13) | (h1 >>> 19); // ROTL32(h1,13); h1 = h1*5+0xe6546b64; shift = 0; nBytes += 4; k1 = 0; } else { k1 |= code << shift; shift += 8; } continue; ***/ } else if (code < 0x800) { k2 = (0xC0 | (code >> 6)) | ((0x80 | (code & 0x3F)) << 8); bits = 16; } else if (code < 0xD800 || code > 0xDFFF || pos >= end) { // we check for pos>=end to encode an unpaired surrogate as 3 bytes. k2 = (0xE0 | (code >> 12)) | ((0x80 | ((code >> 6) & 0x3F)) << 8) | ((0x80 | (code & 0x3F)) << 16); bits = 24; } else { // surrogate pair // int utf32 = pos < end ? (int) data.charAt(pos++) : 0; int utf32 = (int) data.charAt(pos++); utf32 = ((code - 0xD7C0) << 10) + (utf32 & 0x3FF); k2 = (0xff & (0xF0 | (utf32 >> 18))) | ((0x80 | ((utf32 >> 12) & 0x3F))) << 8 | ((0x80 | ((utf32 >> 6) & 0x3F))) << 16 | (0x80 | (utf32 & 0x3F)) << 24; bits = 32; } k1 |= k2 << shift; // int used_bits = 32 - shift; // how many bits of k2 were used in k1. // int unused_bits = bits - used_bits; // (bits-(32-shift)) == bits+shift-32 == bits-newshift shift += bits; if (shift >= 32) { // mix after we have a complete word k1 *= c1; k1 = (k1 << 15) | (k1 >>> 17); // ROTL32(k1,15); k1 *= c2; h1 ^= k1; h1 = (h1 << 13) | (h1 >>> 19); // ROTL32(h1,13); h1 = h1 * 5 + 0xe6546b64; shift -= 32; // unfortunately, java won't let you shift 32 bits off, so we need to check for 0 if (shift != 0) { k1 = k2 >>> (bits - shift); // bits used == bits - newshift } else { k1 = 0; } nBytes += 4; } } // inner // handle tail if (shift > 0) { nBytes += shift >> 3; k1 *= c1; k1 = (k1 << 15) | (k1 >>> 17); // ROTL32(k1,15); k1 *= c2; h1 ^= k1; } // finalization h1 ^= nBytes; // fmix(h1); h1 ^= h1 >>> 16; h1 *= 0x85ebca6b; h1 ^= h1 >>> 13; h1 *= 0xc2b2ae35; h1 ^= h1 >>> 16; return h1; } /** * Returns the MurmurHash3_x64_128 hash, placing the result in "out". */ private static void murmurhash3_x64_128(byte[] key, int offset, int len, int seed, HashCode128 out) { // The original algorithm does have a 32 bit unsigned seed. // We have to mask to match the behavior of the unsigned types and prevent sign extension. long h1 = seed & 0x00000000FFFFFFFFL; long h2 = seed & 0x00000000FFFFFFFFL; int roundedEnd = offset + (len & 0xFFFFFFF0); // round down to 16 byte block for (int i = offset; i < roundedEnd; i += 16) { long k1 = getLongLittleEndian(key, i); long k2 = getLongLittleEndian(key, i + 8); k1 *= c1; k1 = Long.rotateLeft(k1, 31); k1 *= c2; h1 ^= k1; h1 = Long.rotateLeft(h1, 27); h1 += h2; h1 = h1 * 5 + 0x52dce729; k2 *= c2; k2 = Long.rotateLeft(k2, 33); k2 *= c1; h2 ^= k2; h2 = Long.rotateLeft(h2, 31); h2 += h1; h2 = h2 * 5 + 0x38495ab5; } long k1 = 0; long k2 = 0; switch (len & 15) { case 15: k2 = (key[roundedEnd + 14] & 0xffL) << 48; case 14: k2 |= (key[roundedEnd + 13] & 0xffL) << 40; case 13: k2 |= (key[roundedEnd + 12] & 0xffL) << 32; case 12: k2 |= (key[roundedEnd + 11] & 0xffL) << 24; case 11: k2 |= (key[roundedEnd + 10] & 0xffL) << 16; case 10: k2 |= (key[roundedEnd + 9] & 0xffL) << 8; case 9: k2 |= (key[roundedEnd + 8] & 0xffL); k2 *= c2; k2 = Long.rotateLeft(k2, 33); k2 *= c1; h2 ^= k2; case 8: k1 = ((long) key[roundedEnd + 7]) << 56; case 7: k1 |= (key[roundedEnd + 6] & 0xffL) << 48; case 6: k1 |= (key[roundedEnd + 5] & 0xffL) << 40; case 5: k1 |= (key[roundedEnd + 4] & 0xffL) << 32; case 4: k1 |= (key[roundedEnd + 3] & 0xffL) << 24; case 3: k1 |= (key[roundedEnd + 2] & 0xffL) << 16; case 2: k1 |= (key[roundedEnd + 1] & 0xffL) << 8; case 1: k1 |= (key[roundedEnd] & 0xffL); k1 *= c1; k1 = Long.rotateLeft(k1, 31); k1 *= c2; h1 ^= k1; } //---------- // finalization h1 ^= len; h2 ^= len; h1 += h2; h2 += h1; h1 = fmix64(h1); h2 = fmix64(h2); h1 += h2; h2 += h1; out.val1 = h1; out.val2 = h2; } // String-optimized 128-bit version added by konstantin.sobolev@gmail.com /** * Returns the MurmurHash3_x86_128 hash of the UTF-8 bytes of the String without actually encoding * the string to a temporary buffer. Does not check if input is properly encoded. * * @param data data to encode * @param offset start offset * @param len length * @param seed seed * @param buf19 temporary 19-byte buffer to use. New one will be allocated if {@code null} * @param out output pair to write results to */ private static void murmurhash3_x64_128(CharSequence data, int offset, int len, int seed, byte[] buf19, HashCode128 out) { final byte[] encoded = buf19 == null ? new byte[19] : buf19; // The original algorithm does have a 32 bit unsigned seed. // We have to mask to match the behavior of the unsigned types and prevent sign extension. long h1 = seed & 0x00000000FFFFFFFFL; long h2 = seed & 0x00000000FFFFFFFFL; int encOffset = 0; int bytes = 0; int pos = offset; int end = offset + len; while (true) { // decode at least 16 bytes while (encOffset < 16 && pos < end) { char code = data.charAt(pos++); if (code < 0x80) { encoded[encOffset++] = (byte) code; } else if (code < 0x800) { encoded[encOffset++] = (byte) (0xc0 | code >> 6); encoded[encOffset++] = (byte) (0x80 | (code & 0x3f)); } else if (code < 0xD800 || code > 0xDFFF || pos >= end) { // we check for pos>=end to encode an unpaired surrogate as 3 bytes. encoded[encOffset++] = (byte) (0xe0 | ((code >> 12))); encoded[encOffset++] = (byte) (0x80 | ((code >> 6) & 0x3f)); encoded[encOffset++] = (byte) (0x80 | (code & 0x3f)); } else { // surrogate pair int utf32 = (int) data.charAt(pos++); utf32 = ((code - 0xD7C0) << 10) + (utf32 & 0x3FF); encoded[encOffset++] = (byte) (0xf0 | ((utf32 >> 18))); encoded[encOffset++] = (byte) (0x80 | ((utf32 >> 12) & 0x3f)); encoded[encOffset++] = (byte) (0x80 | ((utf32 >> 6) & 0x3f)); encoded[encOffset++] = (byte) (0x80 | (utf32 & 0x3f)); } } if (encOffset > 15) { long k1 = getLongLittleEndian(encoded, 0); long k2 = getLongLittleEndian(encoded, 8); k1 *= c1; k1 = Long.rotateLeft(k1, 31); k1 *= c2; h1 ^= k1; h1 = Long.rotateLeft(h1, 27); h1 += h2; h1 = h1 * 5 + 0x52dce729; k2 *= c2; k2 = Long.rotateLeft(k2, 33); k2 *= c1; h2 ^= k2; h2 = Long.rotateLeft(h2, 31); h2 += h1; h2 = h2 * 5 + 0x38495ab5; encoded[0] = encoded[16]; encoded[1] = encoded[17]; encoded[2] = encoded[18]; encOffset -= 16; bytes += 16; } else { bytes += encOffset; break; } } // inner long k1 = 0; long k2 = 0; switch (encOffset & 15) { case 15: k2 = (encoded[14] & 0xffL) << 48; case 14: k2 |= (encoded[13] & 0xffL) << 40; case 13: k2 |= (encoded[12] & 0xffL) << 32; case 12: k2 |= (encoded[11] & 0xffL) << 24; case 11: k2 |= (encoded[10] & 0xffL) << 16; case 10: k2 |= (encoded[9] & 0xffL) << 8; case 9: k2 |= (encoded[8] & 0xffL); k2 *= c2; k2 = Long.rotateLeft(k2, 33); k2 *= c1; h2 ^= k2; case 8: k1 = ((long) encoded[7]) << 56; case 7: k1 |= (encoded[6] & 0xffL) << 48; case 6: k1 |= (encoded[5] & 0xffL) << 40; case 5: k1 |= (encoded[4] & 0xffL) << 32; case 4: k1 |= (encoded[3] & 0xffL) << 24; case 3: k1 |= (encoded[2] & 0xffL) << 16; case 2: k1 |= (encoded[1] & 0xffL) << 8; case 1: k1 |= (encoded[0] & 0xffL); k1 *= c1; k1 = Long.rotateLeft(k1, 31); k1 *= c2; h1 ^= k1; } //---------- // finalization h1 ^= bytes; h2 ^= bytes; h1 += h2; h2 += h1; h1 = fmix64(h1); h2 = fmix64(h2); h1 += h2; h2 += h1; out.val1 = h1; out.val2 = h2; } /** * Returns the MurmurHash3_x86_128 hash of the ASCII bytes of the String without actually encoding * the string to a temporary buffer. Warning: will return invalid results if {@code data} * contains non-ASCII characters! No checks are made. * Results are placed in {@code out}. */ private static void murmurhash3_x64_128_ascii(CharSequence data, int offset, int len, int seed, HashCode128 out) { // The original algorithm does have a 32 bit unsigned seed. // We have to mask to match the behavior of the unsigned types and prevent sign extension. long h1 = seed & 0x00000000FFFFFFFFL; long h2 = seed & 0x00000000FFFFFFFFL; int pos = offset; int end = offset + len; while (pos <= end - 16) { long k1 = (data.charAt(pos++) & 0xffL); k1 |= (data.charAt(pos++) & 0xffL) << 8; k1 |= (data.charAt(pos++) & 0xffL) << 16; k1 |= (data.charAt(pos++) & 0xffL) << 24; k1 |= (data.charAt(pos++) & 0xffL) << 32; k1 |= (data.charAt(pos++) & 0xffL) << 40; k1 |= (data.charAt(pos++) & 0xffL) << 48; k1 |= (data.charAt(pos++) & 0xffL) << 56; long k2 = (data.charAt(pos++) & 0xffL); k2 |= (data.charAt(pos++) & 0xffL) << 8; k2 |= (data.charAt(pos++) & 0xffL) << 16; k2 |= (data.charAt(pos++) & 0xffL) << 24; k2 |= (data.charAt(pos++) & 0xffL) << 32; k2 |= (data.charAt(pos++) & 0xffL) << 40; k2 |= (data.charAt(pos++) & 0xffL) << 48; k2 |= (data.charAt(pos++) & 0xffL) << 56; k1 *= c1; k1 = Long.rotateLeft(k1, 31); k1 *= c2; h1 ^= k1; h1 = Long.rotateLeft(h1, 27); h1 += h2; h1 = h1 * 5 + 0x52dce729; k2 *= c2; k2 = Long.rotateLeft(k2, 33); k2 *= c1; h2 ^= k2; h2 = Long.rotateLeft(h2, 31); h2 += h1; h2 = h2 * 5 + 0x38495ab5; } // inner long k1 = 0; long k2 = 0; int tail = end; switch ((end - pos) & 15) { case 15: k2 = (data.charAt(--tail) & 0xffL) << 48; case 14: k2 |= (data.charAt(--tail) & 0xffL) << 40; case 13: k2 |= (data.charAt(--tail) & 0xffL) << 32; case 12: k2 |= (data.charAt(--tail) & 0xffL) << 24; case 11: k2 |= (data.charAt(--tail) & 0xffL) << 16; case 10: k2 |= (data.charAt(--tail) & 0xffL) << 8; case 9: k2 |= (data.charAt(--tail) & 0xffL); k2 *= c2; k2 = Long.rotateLeft(k2, 33); k2 *= c1; h2 ^= k2; case 8: k1 = (data.charAt(--tail) & 0xffL) << 56; case 7: k1 |= (data.charAt(--tail) & 0xffL) << 48; case 6: k1 |= (data.charAt(--tail) & 0xffL) << 40; case 5: k1 |= (data.charAt(--tail) & 0xffL) << 32; case 4: k1 |= (data.charAt(--tail) & 0xffL) << 24; case 3: k1 |= (data.charAt(--tail) & 0xffL) << 16; case 2: k1 |= (data.charAt(--tail) & 0xffL) << 8; case 1: k1 |= (data.charAt(--tail) & 0xffL); k1 *= c1; k1 = Long.rotateLeft(k1, 31); k1 *= c2; h1 ^= k1; } //---------- // finalization h1 ^= len; h2 ^= len; h1 += h2; h2 += h1; h1 = fmix64(h1); h2 = fmix64(h2); h1 += h2; h2 += h1; out.val1 = h1; out.val2 = h2; } } public static int toSeed(String salt) { return (int) murmur3(salt, DEFAULT_STRING_SEED); } public static long murmur3(long value, int seed) { byte[] data = new byte[8]; for (int i = 7; i >= 0; i--) { data[i] = (byte) (value & 0xFFL); value >>= 8; } return MurmurHash3.murmurhash3_x86_32(data, 0, 8, seed); } public static long murmur3(CharSequence charSequence, int seed) { return MurmurHash3.murmurhash3_x86_32(charSequence, 0, charSequence.length(), seed); } }
0
java-sources/ai/salmonbrain/experiment-sdk/0.0.1/ai/salmonbrain/client
java-sources/ai/salmonbrain/experiment-sdk/0.0.1/ai/salmonbrain/client/hash/LongMurmurHash.java
package ai.salmonbrain.client.hash; public class LongMurmurHash implements HashFunction<Long> { @Override public long getHash(Long key, String salt) { return HashFunctions.murmur3(key, HashFunctions.toSeed(salt)); } }
0
java-sources/ai/salmonbrain/experiment-sdk/0.0.1/ai/salmonbrain/client
java-sources/ai/salmonbrain/experiment-sdk/0.0.1/ai/salmonbrain/client/hash/StringMurmurHash.java
package ai.salmonbrain.client.hash; public class StringMurmurHash implements HashFunction<String> { @Override public long getHash(String key, String salt) { return HashFunctions.murmur3(key, HashFunctions.toSeed(salt)); } }
0
java-sources/ai/salmonbrain/experiment-sdk/0.0.1/ai/salmonbrain
java-sources/ai/salmonbrain/experiment-sdk/0.0.1/ai/salmonbrain/experiment/ExperimentConfig.java
package ai.salmonbrain.experiment; public interface ExperimentConfig { String name(); int startPartition(); int endPartition(); int modulo(); int variant(); }
0
java-sources/ai/salmonbrain/experiment-sdk/0.0.1/ai/salmonbrain
java-sources/ai/salmonbrain/experiment-sdk/0.0.1/ai/salmonbrain/experiment/ExperimentConfigSelector.java
package ai.salmonbrain.experiment; import ai.salmonbrain.client.hash.HashFunction; import java.util.List; public class ExperimentConfigSelector<T, E extends ExperimentConfig> { private final Partitioner<T> partitioner; private final HashFunction<T> hashFunction; private final int partitionsNum; public ExperimentConfigSelector(Partitioner<T> partitioner, HashFunction<T> hashFunction, int partitionsNum) { if (partitionsNum < 1) { throw new IllegalArgumentException("Partitions num must be >= 1"); } this.partitioner = partitioner; this.hashFunction = hashFunction; this.partitionsNum = partitionsNum; } public E select(T key, List<E> experiments) { int partition = partitioner.getPartition(key, partitionsNum); for (E experiment : experiments) { if (partition < experiment.startPartition() || partition > experiment.endPartition()) { continue; } int hash = (int) (hashFunction.getHash(key, experiment.name()) % experiment.modulo()); if (hash < 0) { hash += experiment.modulo(); } if (hash == experiment.variant()) { return experiment; } } return null; } }
0
java-sources/ai/salmonbrain/experiment-sdk/0.0.1/ai/salmonbrain
java-sources/ai/salmonbrain/experiment-sdk/0.0.1/ai/salmonbrain/experiment/LongPartitioner.java
package ai.salmonbrain.experiment; public class LongPartitioner implements Partitioner<Long> { @Override public int getPartition(Long id, int partitionsNum) { int p = (int) (id % partitionsNum); return p < 0 ? p + partitionsNum : p; } }
0
java-sources/ai/salmonbrain/experiment-sdk/0.0.1/ai/salmonbrain
java-sources/ai/salmonbrain/experiment-sdk/0.0.1/ai/salmonbrain/experiment/Partitioner.java
package ai.salmonbrain.experiment; public interface Partitioner<T> { int getPartition(T key, int partitionsNum); }
0
java-sources/ai/salmonbrain/experiment-sdk/0.0.1/ai/salmonbrain
java-sources/ai/salmonbrain/experiment-sdk/0.0.1/ai/salmonbrain/experiment/StringPartitioner.java
package ai.salmonbrain.experiment; import ai.salmonbrain.client.hash.HashFunctions; public class StringPartitioner implements Partitioner<String> { private static final int MURMUR_SEED = 0; @Override public int getPartition(String id, int partitionsNum) { int p = (int) (HashFunctions.murmur3(id, MURMUR_SEED) % partitionsNum); return p < 0 ? p + partitionsNum : p; } }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/base/ClassifierMixin.java
package ai.sklearn4j.base; import ai.sklearn4j.core.libraries.numpy.NumpyArray; /** * Mixin class for all classifiers in scikit-learn. */ public abstract class ClassifierMixin { /** * Names of features seen during training. Defined only when `X` has feature names that are all strings. */ private String[] featureNamesIn = null; /** * Number of features seen during training. */ private int numberOfFeatures = 0; /** * The frequency of each class in the training set. * Dimension: (class_count) */ protected NumpyArray<Double> classCounts = null; /** * The list of class IDs. * Dimension: (class_count) */ protected NumpyArray<Long> classes = null; /** * Perform classification on an array of test vectors X. * * @param x Array-like of shape (n_samples, n_features) The input samples. * @return NumpyArray of shape (n_samples,) Predicted target values for X. */ public abstract NumpyArray<Long> predict(NumpyArray<Double> x); /** * Return log-probability estimates for the test vector X. * * @param x array-like of shape (n_samples, n_features) The input samples. * @return array-like of shape (n_samples, n_classes) * Returns the log-probability of the samples for each class in * the model. The columns correspond to the classes in sorted * order, as they appear in the attribute :term:`classes_`. */ public abstract NumpyArray<Double> predictLogProbabilities(NumpyArray<Double> x); /** * Return probability estimates for the test vector X. * * @param x array-like of shape (n_samples, n_features) The input samples. * @return array-like of shape (n_samples, n_classes) * Returns the probability of the samples for each class in * the model. The columns correspond to the classes in sorted * order, as they appear in the attribute :term:`classes_`. */ public abstract NumpyArray<Double> predictProbabilities(NumpyArray<Double> x); /** * Gets the feature names. * * @return The value of feature names. */ public String[] getFeatureNamesIn() { return featureNamesIn; } /** * Sets the feature names. * * @param featureNamesIn New value to be stored. */ public void setFeatureNamesIn(String[] featureNamesIn) { this.featureNamesIn = featureNamesIn; } /** * Gets the number of features. * * @return The value of number of features. */ public int getNumberOfFeatures() { return numberOfFeatures; } /** * Sets the number of features. * * @param numberOfFeatures New value to be stored. */ public void setNumberOfFeatures(int numberOfFeatures) { this.numberOfFeatures = numberOfFeatures; } /** * Gets the class counts. * * @return The value of class counts. */ public NumpyArray<Double> getClassCounts() { return classCounts; } /** * Sets the class counts. * * @param classCounts New value to be stored. */ public void setClassCounts(NumpyArray<Double> classCounts) { this.classCounts = classCounts; } /** * Gets the classes. * * @return The value of classes. */ public NumpyArray<Long> getClasses() { return classes; } /** * Sets the classes. * * @param classes New value to be stored. */ public void setClasses(NumpyArray<Long> classes) { this.classes = classes; } }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/base/TransformerMixin.java
package ai.sklearn4j.base; /** * Mixin class for all transformers in scikit-learn. * * @param <InputType> Type of the input for the transformation. * @param <OutputType> Type of the output for the transformation. */ public abstract class TransformerMixin<InputType, OutputType> { /** * Takes the input array and transforms it. * * @param array The array to transform. * @return The transformed array. */ public abstract OutputType transform(InputType array); /** * Takes a transformed array and reveres the transformation. * * @param array The array to apply reveres transform. * @return The inversed transform of array. */ public abstract InputType inverseTransform(OutputType array); }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/Constants.java
package ai.sklearn4j.core; /** * Constants related to calculations for Classifiers and Regressors */ public class Constants { /** * The number Pi = 3.14 */ public static final double PI = Math.PI; /** * The number e = 2.71 */ public static final double E = Math.E; }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/ScikitLearnCoreException.java
package ai.sklearn4j.core; /** * A custom exception that provides information on what went wrong in the library general processing. */ public class ScikitLearnCoreException extends RuntimeException { /** * Instantiate a new exception object. * * @param message The content of the error. */ public ScikitLearnCoreException(String message) { super(message); } }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/ScikitLearnFeatureNotImplementedException.java
package ai.sklearn4j.core; /** * A custom exception that indicates a feature has not been implemented yet. */ public class ScikitLearnFeatureNotImplementedException extends RuntimeException { /** * Instantiate a new exception object. */ public ScikitLearnFeatureNotImplementedException() { super("This feature has not yet been implemented."); } /** * Instantiate a new exception object. * * @param message The content of the error. */ public ScikitLearnFeatureNotImplementedException(String message) { super(message); } }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/Scipy.java
package ai.sklearn4j.core.libraries; import ai.sklearn4j.core.ScikitLearnFeatureNotImplementedException; import ai.sklearn4j.core.libraries.numpy.Numpy; import ai.sklearn4j.core.libraries.numpy.NumpyArray; /** * Function of the scipy library that was used in scikit-learn. */ public class Scipy { /** * Compute the log of the sum of exponentials of input elements. * See https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.logsumexp.html * * @param data Input array to apply the calculations on. * @param axis The axis used by sum for reduction. * @return The result, np.log(np.sum(np.exp(a))) calculated in a numerically more stable way. */ public static NumpyArray<Double> logSumExponent(NumpyArray<Double> data, int axis) { // https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.logsumexp.html // Calculates np.log(np.sum(np.exp(a))) // return Numpy.log(Numpy.sum(Numpy.exp(data), axis)); NumpyArray<Double> aMax = Numpy.arrayMax(data, axis, true); aMax.applyToEachElement(value -> { if (!Double.isFinite(value)) { return 0.0; } else { return value; } }); NumpyArray<Double> tmp = Numpy.exp(Numpy.subtract(data, aMax)); tmp = Numpy.sum(tmp, axis, false); tmp = Numpy.log(tmp); tmp = Numpy.add(tmp, Numpy.squeeze(aMax)); return tmp; } /** * Utility functions in scipy related to normal distributions. */ public static final class NormalDistribution { /** * Calculate the cumulative distribution function of a normal array. * * @param x The array holding the distribution values. * @return The CDF for the distribution. */ public static double[] cumulativeDistributionFunction(double[] x) { throw new ScikitLearnFeatureNotImplementedException(); } } }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy/INumpyArrayElementOperation.java
package ai.sklearn4j.core.libraries.numpy; /** * An interface to provide a unified view of the operations that can be performed on the * elements of a NumpyArray. * * @param <Type> The type of the NumpyArray. */ public interface INumpyArrayElementOperation<Type> { /** * The operation to be applied to each element in the NumpyArray. * * @param value The value of the element. * @return The calculation on the element. */ Type apply(Type value); }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy/INumpyArrayWrapper.java
package ai.sklearn4j.core.libraries.numpy; /** * Unlike python, Java is a strongly typed language and all the fields should have a predefined type. * This fact complicates the handling of data structures like Numpy arrays where the same interface * is used for all data types. The INumpyArrayWrapper provide a unified view of the underlying data * types. */ public interface INumpyArrayWrapper { /** * Gets the shape of the underlying Numpy array. * * @return The shape of the array as an int[]. */ int[] getShape(); /** * Gets the value of a single element in the numpy array denoted by its indices. * * @param indices The index of the element to be retrieved. * @return An object-wrapped instance of the element in the Numpy array. */ Object get(int... indices); /** * Sets the value of a single element in the numpy array denoted by its indices. * * @param value The new value to be assigned to the numpy element. * @param index The index of the element to be set. */ void set(Object value, int... index); /** * Returns a boolean indicating that the underlying array type is a floating point one or not. * * @return A boolean value indicating floating point of the elements. */ boolean isFloatingPoint(); /** * The space allocated by each element of the numpy array in terms of bits. * * @return Number of bit needed for each element. */ int numberOfBits(); /** * Transposes a numpy array by reversing its dimensions. * * @return The transposed numpy array. */ NumpyArray transpose(); /** * Wraps a subset of the numpy array. This methods works only when slicing the most inner dimensions * of the array. For example, if the shape is [2, 6, 4, 8], wrapInnerSubsetArray(1, 3) is equivalent * to numpy array[1, 3, :, :]. * * @param indices The indices of the first dimensions to keep. * @return A new INumpyArrayWrapper wrapping the inner dimensions. This array has the same reference. */ NumpyArray wrapInnerSubsetArray(int... indices); /** * Gets the native array containing the numpy array data. * * @return The underlying native array. */ Object getRawArray(); }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy/INumpyReduceAxisFunction.java
package ai.sklearn4j.core.libraries.numpy; /** * An interface to provide a unified view of the operations that can be performed on a * specified dimension of a NumpyArray. */ public interface INumpyReduceAxisFunction { /** * The aggregation function that can reduce the values of a NumpyArray dimension. * * @param valuesInAxis The values in the axis. * @return A single value that contains the reduction of the axis. */ Object reduceAxisValues(Object[] valuesInAxis); }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy/Numpy.java
package ai.sklearn4j.core.libraries.numpy; /** * Implementation of the Numpy library APIs. */ public final class Numpy { /** * Returns the indices of the maximum values along an axis. * See: https://numpy.org/doc/stable/reference/generated/numpy.argmax.html * * @param array The input multidimensional array. * @param axis The axis which the argmax should reduce to. * @param keepDimensions A flag to specify whether to keep the reduced dimension in the output. * @return Array of indices into the array. It has the same shape as a.shape with the dimension along axis removed. */ public static <Type> NumpyArray<Long> argmax(NumpyArray<Type> array, int axis, boolean keepDimensions) { NumpyArrayOperationWithAxisReduction<Type, Long> operation = new NumpyArrayOperationWithAxisReduction<>() { @Override public NumpyArray<Long> createInstanceResultNumpyArray(int[] shape) { return NumpyArrayFactory.arrayOfInt64WithShape(shape); } @Override public Object reduceAxisValues(Object[] valuesInAxis) { long result = 0; double max = (double) valuesInAxis[0]; for (int i = 1; i < valuesInAxis.length; i++) { double m = (double) valuesInAxis[i]; if (m > max) { max = m; result = i; } } return result; } }; return operation.apply(array, axis, keepDimensions); } /** * Performs an element-wise power operation on a given NumpyArray. * See: https://numpy.org/doc/stable/reference/generated/numpy.power.html * * @param array Input array. * @param power The value of the power. * @return An array with same dimension with the requested power calculation. */ public static NumpyArray<Double> pow(NumpyArray array, double power) { NumpyArray<Double> result = NumpyArrayFactory.arrayOfDoubleWithShape(array.getShape()); array.applyToEachElementAnsSaveToTarget(result, value -> Math.pow((double) value, power)); return result; } /** * Sums the values of a NumpyArray along a specified axis. * See: https://numpy.org/doc/stable/reference/generated/numpy.sum.html * * @param array Input array. * @param axis Axis along which a sum is performed. * @param keepDimensions A flag to specify whether to keep the reduced dimension in the output. * @return An array with the same shape as a, with the specified axis removed. */ public static NumpyArray sum(NumpyArray array, int axis, boolean keepDimensions) { INumpyReduceAxisFunction function = null; if (!array.isFloatingPoint() && array.numberOfBytes() == NumpyArrayFactory.SIZE_OF_INT_8) { function = (values) -> { byte result = 0; for (Object value : values) { result += (byte) value; } return result; }; } else if (!array.isFloatingPoint() && array.numberOfBytes() == NumpyArrayFactory.SIZE_OF_INT_16) { function = (values) -> { short result = 0; for (Object value : values) { result += (short) value; } return result; }; } else if (!array.isFloatingPoint() && array.numberOfBytes() == NumpyArrayFactory.SIZE_OF_INT_32) { function = (values) -> { int result = 0; for (Object value : values) { result += (int) value; } return result; }; } else if (!array.isFloatingPoint() && array.numberOfBytes() == NumpyArrayFactory.SIZE_OF_INT_64) { function = (values) -> { long result = 0; for (Object value : values) { result += (long) value; } return result; }; } else if (array.isFloatingPoint() && array.numberOfBytes() == NumpyArrayFactory.SIZE_OF_FLOAT) { function = (values) -> { float result = 0; for (Object value : values) { result += (float) value; } return result; }; } else if (array.isFloatingPoint() && array.numberOfBytes() == NumpyArrayFactory.SIZE_OF_DOUBLE) { function = (values) -> { double result = 0; for (Object value : values) { result += (double) value; } return result; }; } INumpyReduceAxisFunction finalFunction = function; NumpyArrayOperationWithAxisReduction<Double, Double> operation = new NumpyArrayOperationWithAxisReduction<>() { @Override public Object reduceAxisValues(Object[] valuesInAxis) { return finalFunction.reduceAxisValues(valuesInAxis); } }; return operation.apply(array, axis, keepDimensions); } /** * Calculate the exponential of all elements in the input array. * https://numpy.org/doc/stable/reference/generated/numpy.exp.html * * @param array Input values. * @return Output array, element-wise exponential of x. */ public static NumpyArray<Double> exp(NumpyArray array) { NumpyArray<Double> result = NumpyArrayFactory.createArrayOfShapeAndTypeInfo(true, NumpyArrayFactory.SIZE_OF_DOUBLE, array.getShape()); array.applyToEachElementAnsSaveToTarget(result, value -> Math.exp((double) value)); return result; } /** * Natural logarithm, element-wise. * <p> * The natural logarithm log is the inverse of the exponential function, so that * log(exp(x)) = x. The natural logarithm is logarithm in base e. * * @param array Input values. * @return Output array, element-wise log of x. */ public static NumpyArray<Double> log(NumpyArray array) { NumpyArray<Double> result = NumpyArrayFactory.createArrayOfShapeAndTypeInfo(true, NumpyArrayFactory.SIZE_OF_DOUBLE, array.getShape()); array.applyToEachElementAnsSaveToTarget(result, value -> Math.log((double) value)); return result; } /** * To ease the add implementation, the code assumes that the array with higher dimensions is * on the left-hand side. In case it is not provided in this format, it should be swapped. This * function checks if it is the case or not. * * @param a1 Array on the left hand-side of the addition. * @param a2 Array on the right hand-side of the addition. * @return A boolean indicating if the values should be swapped or not. */ private static boolean shouldSwapForAdd(NumpyArray a1, NumpyArray a2) { boolean result = false; int[] s1 = a1.getShape(); int[] s2 = a2.getShape(); if (getEffectiveShapeWithRemovingEndingDimensions(s1) < getEffectiveShapeWithRemovingEndingDimensions(s2)) { result = true; } return result; } /** * Gets the effective shape of the array. The effective shape is defined as the number of dimensions * on the left that is followed only by ones. * <p> * Example: * (2, 2) -> (2, 2): Will return 2 * (1, 4) -> (1, 4): Will return 2 * (3, 5, 1, 1) -> (3, 5): Will return 2 * * @param shape Shape to evaluate the effective dimensions. * @return Number of effective dimensions. */ private static int getEffectiveShapeWithRemovingEndingDimensions(int[] shape) { int lastOnes = 0; for (int i = 0; i < shape.length; i++) { if (shape[shape.length - i - 1] == 1) { lastOnes++; } else { break; } } return shape.length - lastOnes; } /** * Checks if two numpy arrays with the given dimensions could be added. If they are incompatible, * an exception is thrown. * * @param shape1 Shape of the array on the left hand-side. * @param shape2 Shape of the array on the right hand-side. */ private static void validateDimensionsForAdd(int[] shape1, int[] shape2) { int effective1 = getEffectiveShapeWithRemovingEndingDimensions(shape1); int effective2 = getEffectiveShapeWithRemovingEndingDimensions(shape2); if (effective1 != effective2 && Math.abs(effective2 - effective1) != 1) { throw new NumpyOperationException("The effective shape of the two numpy array has different number of dimensions."); } // This check is for the case where 2 arrays are added with shapes: a1: [5,3], a2: [3] if ((shape1.length > shape2.length && isShapeEndingLike(shape1, shape2)) || (shape2.length > shape1.length && isShapeEndingLike(shape2, shape1))) { return; } for (int i = 0; i < effective1; i++) { if (shape1[i] != shape2[i] && (shape1[i] != 1 && shape2[i] != 1)) { throw new NumpyOperationException(String.format("Dimension %d of the two numpy arrays doesn't match.", i + 1)); } } } /** * Check if the shape 1 later dimensions are the shape as the one specified by shape 2. * * @param shape1 The base shape to check. * @param shape2 The shorter shape to check. * @return A boolean indicating if shape 1 ends with shape 2. */ private static boolean isShapeEndingLike(int[] shape1, int[] shape2) { boolean result = true; for (int i = 0; i < shape2.length; i++) { if (shape2[shape2.length - i - 1] != shape1[shape1.length - i - 1]) { result = false; break; } } return result; } /** * Subtract two numpy arrays. * * @param a1 Left-hand side of the expression. * @param a2 Right-hand side of the expression. * @return The subtraction result. */ public static NumpyArray subtract(NumpyArray a1, NumpyArray a2) { INumpyArrayElementOperation negate = null; if (a2.isFloatingPoint()) { if (a2.numberOfBytes() == NumpyArrayFactory.SIZE_OF_DOUBLE) { negate = value -> -((double) value); } else if (a2.numberOfBytes() == NumpyArrayFactory.SIZE_OF_FLOAT) { negate = value -> -((float) value); } } else { if (a2.numberOfBytes() == NumpyArrayFactory.SIZE_OF_INT_8) { negate = value -> -((byte) value); } else if (a2.numberOfBytes() == NumpyArrayFactory.SIZE_OF_INT_16) { negate = value -> -((short) value); } else if (a2.numberOfBytes() == NumpyArrayFactory.SIZE_OF_INT_32) { negate = value -> -((int) value); } else if (a2.numberOfBytes() == NumpyArrayFactory.SIZE_OF_INT_64) { negate = value -> -((long) value); } } NumpyArray negA2 = NumpyArrayFactory.createArrayOfShapeAndTypeInfo(a2); INumpyArrayElementOperation finalNegate = negate; a2.applyToEachElementAnsSaveToTarget(negA2, value -> finalNegate.apply(value)); return add(a1, negA2); } /** * Adds two numpy arrays. * * @param a1 Left-hand side of the expression. * @param a2 Right-hand side of the expression. * @return The addition result. */ public static NumpyArray add(NumpyArray a1, NumpyArray a2) { validateDimensionsForAdd(a1.getShape(), a2.getShape()); if (shouldSwapForAdd(a1, a2)) { return add(a2, a1); } boolean isFloatingPoint = a1.isFloatingPoint() || a2.isFloatingPoint(); int size = Math.max(a1.numberOfBytes(), a2.numberOfBytes()); if (!a1.isFloatingPoint()) { size = a2.numberOfBytes(); } else if (!a2.isFloatingPoint()) { size = a1.numberOfBytes(); } NumpyArray result = NumpyArrayFactory.createArrayOfShapeAndTypeInfo(isFloatingPoint, size, a1.getShape()); addInPlace(result, a1, a2, (byte) 1); return result; } /** * Adds a double value to numpy arrays. * * @param array Left-hand side of the expression. * @param value Right-hand side of the expression. * @return The addition result. */ public static NumpyArray<Double> add(NumpyArray array, double value) { NumpyArray<Double> result = NumpyArrayFactory.createArrayOfShapeAndTypeInfo(true, NumpyArrayFactory.SIZE_OF_DOUBLE, array.getShape()); addInPlace(result, array, value); return result; } /** * Subtract a double value from numpy arrays. * * @param array Left-hand side of the expression. * @param value Right-hand side of the expression. * @return The subtraction result. */ public static NumpyArray<Double> subtract(NumpyArray array, double value) { return add(array, -value); } /** * Adds a float value to numpy arrays. * * @param array Left-hand side of the expression. * @param value Right-hand side of the expression. * @return The addition result. */ public static NumpyArray<Float> add(NumpyArray array, float value) { NumpyArray<Float> result = NumpyArrayFactory.createArrayOfShapeAndTypeInfo(true, NumpyArrayFactory.SIZE_OF_FLOAT, array.getShape()); addInPlace(result, array, value); return result; } /** * Subtract a float value from numpy arrays. * * @param array Left-hand side of the expression. * @param value Right-hand side of the expression. * @return The subtraction result. */ public static NumpyArray<Float> subtract(NumpyArray array, float value) { return add(array, -value); } /** * Adds a byte value to numpy arrays. * * @param array Left-hand side of the expression. * @param value Right-hand side of the expression. * @return The addition result. */ public static NumpyArray add(NumpyArray array, byte value) { NumpyArray result = NumpyArrayFactory.createArrayOfShapeAndTypeInfo(false, NumpyArrayFactory.SIZE_OF_INT_8, array.getShape()); addInPlace(result, array, value); return result; } /** * Subtract a byte value from numpy arrays. * * @param array Left-hand side of the expression. * @param value Right-hand side of the expression. * @return The subtraction result. */ public static NumpyArray subtract(NumpyArray array, byte value) { return add(array, (byte) -value); } /** * Adds a short value to numpy arrays. * * @param array Left-hand side of the expression. * @param value Right-hand side of the expression. * @return The addition result. */ public static NumpyArray add(NumpyArray array, short value) { NumpyArray result = NumpyArrayFactory.createArrayOfShapeAndTypeInfo(false, NumpyArrayFactory.SIZE_OF_INT_16, array.getShape()); addInPlace(result, array, value); return result; } /** * Subtract a short value from numpy arrays. * * @param array Left-hand side of the expression. * @param value Right-hand side of the expression. * @return The subtraction result. */ public static NumpyArray subtract(NumpyArray array, short value) { return add(array, (short) -value); } /** * Adds a int value to numpy arrays. * * @param array Left-hand side of the expression. * @param value Right-hand side of the expression. * @return The addition result. */ public static NumpyArray add(NumpyArray array, int value) { NumpyArray result = NumpyArrayFactory.createArrayOfShapeAndTypeInfo(false, NumpyArrayFactory.SIZE_OF_INT_32, array.getShape()); addInPlace(result, array, value); return result; } /** * Subtract a int value from numpy arrays. * * @param array Left-hand side of the expression. * @param value Right-hand side of the expression. * @return The subtraction result. */ public static NumpyArray subtract(NumpyArray array, int value) { return add(array, -value); } /** * Adds a long value to numpy arrays. * * @param array Left-hand side of the expression. * @param value Right-hand side of the expression. * @return The addition result. */ public static NumpyArray add(NumpyArray array, long value) { NumpyArray result = NumpyArrayFactory.createArrayOfShapeAndTypeInfo(false, NumpyArrayFactory.SIZE_OF_INT_64, array.getShape()); addInPlace(result, array, value); return result; } /** * Subtract a long value from numpy arrays. * * @param array Left-hand side of the expression. * @param value Right-hand side of the expression. * @return The subtraction result. */ public static NumpyArray subtract(NumpyArray array, long value) { return add(array, -value); } /** * Adds two numpy array and stores the result into a target array. * * @param target The target array that stores the results. * @param a1 The left-hand side of the expression. * @param a2 The right-hand side of the expression. * @param sign A sign value to multiply by the right-hand side. The value of this parameter is either 1 or -1. The -1 is used to implement subtraction. */ private static void addInPlace(NumpyArray target, NumpyArray a1, NumpyArray a2, byte sign) { if (a2.isSingleValueArray()) { Object singleValue = a2.getSingleValue(); if (target.isFloatingPoint()) { if (target.numberOfBytes() == NumpyArrayFactory.SIZE_OF_DOUBLE) { addInPlace(target, a1, ((double) singleValue) * sign); } else if (target.numberOfBytes() == NumpyArrayFactory.SIZE_OF_FLOAT) { addInPlace(target, a1, ((double) singleValue) * sign); } } else { if (target.numberOfBytes() == NumpyArrayFactory.SIZE_OF_INT_8) { addInPlace(target, a1, ((byte) singleValue) * sign); } else if (target.numberOfBytes() == NumpyArrayFactory.SIZE_OF_INT_16) { addInPlace(target, a1, ((short) singleValue) * sign); } else if (target.numberOfBytes() == NumpyArrayFactory.SIZE_OF_INT_32) { addInPlace(target, a1, ((int) singleValue) * sign); } else if (target.numberOfBytes() == NumpyArrayFactory.SIZE_OF_INT_64) { addInPlace(target, a1, ((long) singleValue) * sign); } } } else if (a1.numberOfDimensions() > 1 && a2.numberOfDimensions() == 1) { int[] leftNoneCommonShape = new int[a1.numberOfDimensions() - 1]; int[] index = new int[a1.numberOfDimensions()]; for (int i = 0; i < leftNoneCommonShape.length; i++) { leftNoneCommonShape[i] = a1.getShape()[i]; } int[] counter = new int[leftNoneCommonShape.length + 1]; int rightShape = a2.getShape()[0]; do { NumpyArray.addCounter(counter, leftNoneCommonShape); for (int i = 0; i < leftNoneCommonShape.length; i++) { index[i] = counter[i]; } for (int i = 0; i < rightShape; i++) { index[index.length - 1] = i; Object value = null; if (target.isFloatingPoint()) { if (target.numberOfBytes() == NumpyArrayFactory.SIZE_OF_DOUBLE) { value = (double) a1.get(index) + sign * (double) a2.get(i); } else if (target.numberOfBytes() == NumpyArrayFactory.SIZE_OF_FLOAT) { value = (float) a1.get(index) + sign * (float) a2.get(i); } } else { if (target.numberOfBytes() == NumpyArrayFactory.SIZE_OF_INT_8) { value = (byte) a1.get(index) + sign * (byte) a2.get(i); } else if (target.numberOfBytes() == NumpyArrayFactory.SIZE_OF_INT_16) { value = (short) a1.get(index) + sign * (short) a2.get(i); } else if (target.numberOfBytes() == NumpyArrayFactory.SIZE_OF_INT_32) { value = (int) a1.get(index) + sign * (int) a2.get(i); } else if (target.numberOfBytes() == NumpyArrayFactory.SIZE_OF_INT_64) { value = (long) a1.get(index) + sign * (long) a2.get(i); } } target.set(value, index); } } while (counter[counter.length - 1] == 0); } else if (a1.numberOfDimensions() == 1 && a2.numberOfDimensions() == 1) { int firstDim = target.getShape()[0]; for (int i = 0; i < firstDim; i++) { Object value = null; if (target.isFloatingPoint()) { if (target.numberOfBytes() == NumpyArrayFactory.SIZE_OF_DOUBLE) { value = (double) a1.get(i) + sign * (double) a2.get(i); } else if (target.numberOfBytes() == NumpyArrayFactory.SIZE_OF_FLOAT) { value = (float) a1.get(i) + sign * (float) a2.get(i); } } else { if (target.numberOfBytes() == NumpyArrayFactory.SIZE_OF_INT_8) { value = (byte) a1.get(i) + sign * (byte) a2.get(i); } else if (target.numberOfBytes() == NumpyArrayFactory.SIZE_OF_INT_16) { value = (short) a1.get(i) + sign * (short) a2.get(i); } else if (target.numberOfBytes() == NumpyArrayFactory.SIZE_OF_INT_32) { value = (int) a1.get(i) + sign * (int) a2.get(i); } else if (target.numberOfBytes() == NumpyArrayFactory.SIZE_OF_INT_64) { value = (long) a1.get(i) + sign * (long) a2.get(i); } } target.set(value, i); } } else { int firstDim = target.getShape()[0]; for (int i = 0; i < firstDim; i++) { NumpyArray leftWrap = a1.wrapInnerSubsetArray(i); NumpyArray rightWrap = null; if (a2.getShape()[0] == 1) { rightWrap = a2.wrapInnerSubsetArray(0); } else { rightWrap = a2.wrapInnerSubsetArray(i); } addInPlace(target.wrapInnerSubsetArray(i), leftWrap, rightWrap, sign); } } } /** * Adds a double value to a numpy array. * * @param target The array that stores the calculation. * @param array The left-hand side of the expression. * @param value The value to be added. */ private static void addInPlace(NumpyArray target, NumpyArray array, double value) { array.applyToEachElementAnsSaveToTarget(target, element -> value + (double) element); } /** * Adds a float value to a numpy array. * * @param target The array that stores the calculation. * @param array The left-hand side of the expression. * @param value The value to be added. */ private static void addInPlace(NumpyArray target, NumpyArray array, float value) { array.applyToEachElementAnsSaveToTarget(target, element -> value + (float) element); } /** * Adds a long value to a numpy array. * * @param target The array that stores the calculation. * @param array The left-hand side of the expression. * @param value The value to be added. */ private static void addInPlace(NumpyArray target, NumpyArray array, long value) { array.applyToEachElementAnsSaveToTarget(target, element -> value + (long) element); } /** * Adds a int value to a numpy array. * * @param target The array that stores the calculation. * @param array The left-hand side of the expression. * @param value The value to be added. */ private static void addInPlace(NumpyArray target, NumpyArray array, int value) { array.applyToEachElementAnsSaveToTarget(target, element -> value + (int) element); } /** * Adds a short value to a numpy array. * * @param target The array that stores the calculation. * @param array The left-hand side of the expression. * @param value The value to be added. */ private static void addInPlace(NumpyArray target, NumpyArray array, short value) { array.applyToEachElementAnsSaveToTarget(target, element -> value + (short) element); } /** * Adds a byte value to a numpy array. * * @param target The array that stores the calculation. * @param array The left-hand side of the expression. * @param value The value to be added. */ private static void addInPlace(NumpyArray target, NumpyArray array, byte value) { array.applyToEachElementAnsSaveToTarget(target, element -> value + (byte) element); } /** * Multiplies two numpy arrays. * * @param a1 Left-hand side of the expression. * @param a2 Right-hand side of the expression. * @return The multiplication result. */ public static NumpyArray multiply(NumpyArray a1, NumpyArray a2) { validateDimensionsForAdd(a1.getShape(), a2.getShape()); if (shouldSwapForAdd(a1, a2)) { return multiply(a2, a1); } boolean isFloatingPoint = a1.isFloatingPoint() || a2.isFloatingPoint(); int size = Math.max(a1.numberOfBytes(), a2.numberOfBytes()); if (!a1.isFloatingPoint()) { size = a2.numberOfBytes(); } else if (!a2.isFloatingPoint()) { size = a1.numberOfBytes(); } NumpyArray result = NumpyArrayFactory.createArrayOfShapeAndTypeInfo(isFloatingPoint, size, a1.getShape()); multiplyInPlace(result, a1, a2); return result; } /** * Multiplies two numpy array and stores the result into a target array. * * @param target The target array that stores the results. * @param a1 The left-hand side of the expression. * @param a2 The right-hand side of the expression. */ private static void multiplyInPlace(NumpyArray target, NumpyArray a1, NumpyArray a2) { if (a2.isSingleValueArray()) { Object singleValue = a2.getSingleValue(); if (target.isFloatingPoint()) { if (target.numberOfBytes() == NumpyArrayFactory.SIZE_OF_DOUBLE) { multiplyInPlace(target, a1, ((double) singleValue)); } else if (target.numberOfBytes() == NumpyArrayFactory.SIZE_OF_FLOAT) { multiplyInPlace(target, a1, ((double) singleValue)); } } else { if (target.numberOfBytes() == NumpyArrayFactory.SIZE_OF_INT_8) { multiplyInPlace(target, a1, ((byte) singleValue)); } else if (target.numberOfBytes() == NumpyArrayFactory.SIZE_OF_INT_16) { multiplyInPlace(target, a1, ((short) singleValue)); } else if (target.numberOfBytes() == NumpyArrayFactory.SIZE_OF_INT_32) { multiplyInPlace(target, a1, ((int) singleValue)); } else if (target.numberOfBytes() == NumpyArrayFactory.SIZE_OF_INT_64) { multiplyInPlace(target, a1, ((long) singleValue)); } } } else if (a1.numberOfDimensions() > 1 && a2.numberOfDimensions() == 1) { int[] leftNoneCommonShape = new int[a1.numberOfDimensions() - 1]; int[] index = new int[a1.numberOfDimensions()]; for (int i = 0; i < leftNoneCommonShape.length; i++) { leftNoneCommonShape[i] = a1.getShape()[i]; } int[] counter = new int[leftNoneCommonShape.length + 1]; int rightShape = a2.getShape()[0]; do { NumpyArray.addCounter(counter, leftNoneCommonShape); for (int i = 0; i < leftNoneCommonShape.length; i++) { index[i] = counter[i]; } for (int i = 0; i < rightShape; i++) { index[index.length - 1] = i; Object value = null; if (target.isFloatingPoint()) { if (target.numberOfBytes() == NumpyArrayFactory.SIZE_OF_DOUBLE) { value = (double) a1.get(index) * (double) a2.get(i); } else if (target.numberOfBytes() == NumpyArrayFactory.SIZE_OF_FLOAT) { value = (float) a1.get(index) * (float) a2.get(i); } } else { if (target.numberOfBytes() == NumpyArrayFactory.SIZE_OF_INT_8) { value = (byte) a1.get(index) * (byte) a2.get(i); } else if (target.numberOfBytes() == NumpyArrayFactory.SIZE_OF_INT_16) { value = (short) a1.get(index) * (short) a2.get(i); } else if (target.numberOfBytes() == NumpyArrayFactory.SIZE_OF_INT_32) { value = (int) a1.get(index) * (int) a2.get(i); } else if (target.numberOfBytes() == NumpyArrayFactory.SIZE_OF_INT_64) { value = (long) a1.get(index) * (long) a2.get(i); } } target.set(value, index); } } while (counter[counter.length - 1] == 0); } else if (a1.numberOfDimensions() == 1 && a2.numberOfDimensions() == 1) { int firstDim = target.getShape()[0]; for (int i = 0; i < firstDim; i++) { Object value = null; if (target.isFloatingPoint()) { if (target.numberOfBytes() == NumpyArrayFactory.SIZE_OF_DOUBLE) { value = (double) a1.get(i) * (double) a2.get(i); } else if (target.numberOfBytes() == NumpyArrayFactory.SIZE_OF_FLOAT) { value = (float) a1.get(i) * (float) a2.get(i); } } else { if (target.numberOfBytes() == NumpyArrayFactory.SIZE_OF_INT_8) { value = (byte) a1.get(i) * (byte) a2.get(i); } else if (target.numberOfBytes() == NumpyArrayFactory.SIZE_OF_INT_16) { value = (short) a1.get(i) * (short) a2.get(i); } else if (target.numberOfBytes() == NumpyArrayFactory.SIZE_OF_INT_32) { value = (int) a1.get(i) * (int) a2.get(i); } else if (target.numberOfBytes() == NumpyArrayFactory.SIZE_OF_INT_64) { value = (long) a1.get(i) * (long) a2.get(i); } } target.set(value, i); } } else { int firstDim = target.getShape()[0]; for (int i = 0; i < firstDim; i++) { NumpyArray leftWrap = a1.wrapInnerSubsetArray(i); NumpyArray rightWrap = null; if (a2.getShape()[0] == 1) { rightWrap = a2.wrapInnerSubsetArray(0); } else { rightWrap = a2.wrapInnerSubsetArray(i); } multiplyInPlace(target.wrapInnerSubsetArray(i), leftWrap, rightWrap); } } } /** * Multiplies a double value by a numpy array. * * @param target The array that stores the calculation. * @param array The left-hand side of the expression. * @param value The value to be multiplied by. */ private static void multiplyInPlace(NumpyArray target, NumpyArray array, double value) { array.applyToEachElementAnsSaveToTarget(target, element -> value * (double) element); } /** * Multiplies a float value by a numpy array. * * @param target The array that stores the calculation. * @param array The left-hand side of the expression. * @param value The value to be multiplied by. */ private static void multiplyInPlace(NumpyArray target, NumpyArray array, float value) { array.applyToEachElementAnsSaveToTarget(target, element -> value * (float) element); } /** * Multiplies a long value by a numpy array. * * @param target The array that stores the calculation. * @param array The left-hand side of the expression. * @param value The value to be multiplied by. */ private static void multiplyInPlace(NumpyArray target, NumpyArray array, long value) { array.applyToEachElementAnsSaveToTarget(target, element -> value * (long) element); } /** * Multiplies a int value by a numpy array. * * @param target The array that stores the calculation. * @param array The left-hand side of the expression. * @param value The value to be multiplied by. */ private static void multiplyInPlace(NumpyArray target, NumpyArray array, int value) { array.applyToEachElementAnsSaveToTarget(target, element -> value * (int) element); } /** * Multiplies a short value by a numpy array. * * @param target The array that stores the calculation. * @param array The left-hand side of the expression. * @param value The value to be multiplied by. */ private static void multiplyInPlace(NumpyArray target, NumpyArray array, short value) { array.applyToEachElementAnsSaveToTarget(target, element -> value * (short) element); } /** * Multiplies a byte value by a numpy array. * * @param target The array that stores the calculation. * @param array The left-hand side of the expression. * @param value The value to be multiplied by. */ private static void multiplyInPlace(NumpyArray target, NumpyArray array, byte value) { array.applyToEachElementAnsSaveToTarget(target, element -> value * (byte) element); } /** * Multiplies a numpy array by a double value. The operation is element-wise. * * @param array The input array to be multiplied. * @param factor The value to be multiplied with. * @return A numpy array of the calculation result. */ public static NumpyArray<Double> multiply(NumpyArray<Double> array, double factor) { NumpyArray<Double> result = NumpyArrayFactory.createArrayOfShapeAndTypeInfo(array); array.applyToEachElementAnsSaveToTarget(result, value -> value * factor); return result; } /** * Multiplies a numpy array by a float value. The operation is element-wise. * * @param array The input array to be multiplied. * @param factor The value to be multiplied with. * @return A numpy array of the calculation result. */ public static NumpyArray<Float> multiply(NumpyArray<Float> array, float factor) { NumpyArray<Float> result = NumpyArrayFactory.createArrayOfShapeAndTypeInfo(array); array.applyToEachElementAnsSaveToTarget(result, value -> value * factor); return result; } /** * Divides two numpy arrays. * * @param a1 Left-hand side of the expression. * @param a2 Right-hand side of the expression. * @return The multiplication result. */ public static NumpyArray divide(NumpyArray a1, NumpyArray a2) { validateDimensionsForAdd(a1.getShape(), a2.getShape()); if (shouldSwapForAdd(a1, a2)) { throw new NumpyOperationException("This division is not supported."); } boolean isFloatingPoint = a1.isFloatingPoint() || a2.isFloatingPoint(); int size = Math.max(a1.numberOfBytes(), a2.numberOfBytes()); if (!a1.isFloatingPoint()) { size = a2.numberOfBytes(); } else if (!a2.isFloatingPoint()) { size = a1.numberOfBytes(); } NumpyArray result = NumpyArrayFactory.createArrayOfShapeAndTypeInfo(isFloatingPoint, size, a1.getShape()); divideInPlace(result, a1, a2); return result; } /** * Divides two numpy array and stores the result into a target array. * * @param target The target array that stores the results. * @param a1 The left-hand side of the expression. * @param a2 The right-hand side of the expression. */ private static void divideInPlace(NumpyArray target, NumpyArray a1, NumpyArray a2) { if (a2.isSingleValueArray()) { Object singleValue = a2.getSingleValue(); if (target.isFloatingPoint()) { if (target.numberOfBytes() == NumpyArrayFactory.SIZE_OF_DOUBLE) { divideInPlace(target, a1, ((double) singleValue)); } else if (target.numberOfBytes() == NumpyArrayFactory.SIZE_OF_FLOAT) { divideInPlace(target, a1, ((double) singleValue)); } } else { if (target.numberOfBytes() == NumpyArrayFactory.SIZE_OF_INT_8) { divideInPlace(target, a1, ((byte) singleValue)); } else if (target.numberOfBytes() == NumpyArrayFactory.SIZE_OF_INT_16) { divideInPlace(target, a1, ((short) singleValue)); } else if (target.numberOfBytes() == NumpyArrayFactory.SIZE_OF_INT_32) { divideInPlace(target, a1, ((int) singleValue)); } else if (target.numberOfBytes() == NumpyArrayFactory.SIZE_OF_INT_64) { divideInPlace(target, a1, ((long) singleValue)); } } } else if (a1.numberOfDimensions() > 1 && a2.numberOfDimensions() == 1) { int[] leftNoneCommonShape = new int[a1.numberOfDimensions() - 1]; int[] index = new int[a1.numberOfDimensions()]; for (int i = 0; i < leftNoneCommonShape.length; i++) { leftNoneCommonShape[i] = a1.getShape()[i]; } int[] counter = new int[leftNoneCommonShape.length + 1]; int rightShape = a2.getShape()[0]; do { NumpyArray.addCounter(counter, leftNoneCommonShape); for (int i = 0; i < leftNoneCommonShape.length; i++) { index[i] = counter[i]; } for (int i = 0; i < rightShape; i++) { index[index.length - 1] = i; Object value = null; if (target.isFloatingPoint()) { if (target.numberOfBytes() == NumpyArrayFactory.SIZE_OF_DOUBLE) { value = (double) a1.get(index) / (double) a2.get(i); } else if (target.numberOfBytes() == NumpyArrayFactory.SIZE_OF_FLOAT) { value = (float) a1.get(index) / (float) a2.get(i); } } else { if (target.numberOfBytes() == NumpyArrayFactory.SIZE_OF_INT_8) { value = (byte) a1.get(index) / (byte) a2.get(i); } else if (target.numberOfBytes() == NumpyArrayFactory.SIZE_OF_INT_16) { value = (short) a1.get(index) / (short) a2.get(i); } else if (target.numberOfBytes() == NumpyArrayFactory.SIZE_OF_INT_32) { value = (int) a1.get(index) / (int) a2.get(i); } else if (target.numberOfBytes() == NumpyArrayFactory.SIZE_OF_INT_64) { value = (long) a1.get(index) / (long) a2.get(i); } } target.set(value, index); } } while (counter[counter.length - 1] == 0); } else if (a1.numberOfDimensions() == 1 && a2.numberOfDimensions() == 1) { int firstDim = target.getShape()[0]; for (int i = 0; i < firstDim; i++) { Object value = null; if (target.isFloatingPoint()) { if (target.numberOfBytes() == NumpyArrayFactory.SIZE_OF_DOUBLE) { value = (double) a1.get(i) / (double) a2.get(i); } else if (target.numberOfBytes() == NumpyArrayFactory.SIZE_OF_FLOAT) { value = (float) a1.get(i) / (float) a2.get(i); } } else { if (target.numberOfBytes() == NumpyArrayFactory.SIZE_OF_INT_8) { value = (byte) a1.get(i) / (byte) a2.get(i); } else if (target.numberOfBytes() == NumpyArrayFactory.SIZE_OF_INT_16) { value = (short) a1.get(i) / (short) a2.get(i); } else if (target.numberOfBytes() == NumpyArrayFactory.SIZE_OF_INT_32) { value = (int) a1.get(i) / (int) a2.get(i); } else if (target.numberOfBytes() == NumpyArrayFactory.SIZE_OF_INT_64) { value = (long) a1.get(i) / (long) a2.get(i); } } target.set(value, i); } } else { int firstDim = target.getShape()[0]; for (int i = 0; i < firstDim; i++) { NumpyArray leftWrap = a1.wrapInnerSubsetArray(i); NumpyArray rightWrap = null; if (a2.getShape()[0] == 1) { rightWrap = a2.wrapInnerSubsetArray(0); } else { rightWrap = a2.wrapInnerSubsetArray(i); } divideInPlace(target.wrapInnerSubsetArray(i), leftWrap, rightWrap); } } } /** * Divides a double value by a numpy array. * * @param target The array that stores the calculation. * @param array The left-hand side of the expression. * @param value The value to be divided by. */ private static void divideInPlace(NumpyArray target, NumpyArray array, double value) { array.applyToEachElementAnsSaveToTarget(target, element -> ((double) element) / value); } /** * Divides a float value by a numpy array. * * @param target The array that stores the calculation. * @param array The left-hand side of the expression. * @param value The value to be divided by. */ private static void divideInPlace(NumpyArray target, NumpyArray array, float value) { array.applyToEachElementAnsSaveToTarget(target, element -> ((float) element) / value); } /** * Divides a long value by a numpy array. * * @param target The array that stores the calculation. * @param array The left-hand side of the expression. * @param value The value to be divided by. */ private static void divideInPlace(NumpyArray target, NumpyArray array, long value) { array.applyToEachElementAnsSaveToTarget(target, element -> ((long) element) / value); } /** * Divides a int value by a numpy array. * * @param target The array that stores the calculation. * @param array The left-hand side of the expression. * @param value The value to be divided by. */ private static void divideInPlace(NumpyArray target, NumpyArray array, int value) { array.applyToEachElementAnsSaveToTarget(target, element -> ((int) element) / value); } /** * Divides a short value by a numpy array. * * @param target The array that stores the calculation. * @param array The left-hand side of the expression. * @param value The value to be divided by. */ private static void divideInPlace(NumpyArray target, NumpyArray array, short value) { array.applyToEachElementAnsSaveToTarget(target, element -> ((short) element) / value); } /** * Divides a byte value by a numpy array. * * @param target The array that stores the calculation. * @param array The left-hand side of the expression. * @param value The value to be divided by. */ private static void divideInPlace(NumpyArray target, NumpyArray array, byte value) { array.applyToEachElementAnsSaveToTarget(target, element -> ((byte) element) / value); } /** * Divides a numpy array by a double value. The operation is element-wise. * * @param array The input array to be divided. * @param factor The value to be divided by. * @return A numpy array of the calculation result. */ public static NumpyArray<Double> divide(NumpyArray<Double> array, double factor) { return multiply(array, 1.0 / factor); } /** * Divides a numpy array by a float value. The operation is element-wise. * * @param array The input array to be divided. * @param factor The value to be divided by. * @return A numpy array of the calculation result. */ public static NumpyArray<Float> divide(NumpyArray<Float> array, float factor) { return multiply(array, 1.0f / factor); } /** * Wraps an atomic double value into a 2 dimensional array. * * @param value The value to be wrapped into an array. * @return A two dimensional array that wraps the given value. */ public static NumpyArray<Double> atLeast2D(double value) { NumpyArray<Double> result = NumpyArrayFactory.createArrayOfShapeAndTypeInfo(true, NumpyArrayFactory.SIZE_OF_DOUBLE, new int[]{1, 1}); result.set(value, 0, 0); return result; } /** * Wraps an atomic float value into a 2 dimensional array. * * @param value The value to be wrapped into an array. * @return A two dimensional array that wraps the given value. */ public static NumpyArray<Float> atLeast2D(float value) { NumpyArray<Float> result = NumpyArrayFactory.createArrayOfShapeAndTypeInfo(true, NumpyArrayFactory.SIZE_OF_FLOAT, new int[]{1, 1}); result.set(value, 0, 0); return result; } /** * Wraps an atomic long value into a 2 dimensional array. * * @param value The value to be wrapped into an array. * @return A two dimensional array that wraps the given value. */ public static NumpyArray<Long> atLeast2D(long value) { NumpyArray<Long> result = NumpyArrayFactory.createArrayOfShapeAndTypeInfo(false, NumpyArrayFactory.SIZE_OF_INT_64, new int[]{1, 1}); result.set(value, 0, 0); return result; } /** * Wraps an atomic int value into a 2 dimensional array. * * @param value The value to be wrapped into an array. * @return A two dimensional array that wraps the given value. */ public static NumpyArray<Integer> atLeast2D(int value) { NumpyArray<Integer> result = NumpyArrayFactory.createArrayOfShapeAndTypeInfo(false, NumpyArrayFactory.SIZE_OF_INT_32, new int[]{1, 1}); result.set(value, 0, 0); return result; } /** * Wraps an atomic short value into a 2 dimensional array. * * @param value The value to be wrapped into an array. * @return A two dimensional array that wraps the given value. */ public static NumpyArray<Short> atLeast2D(short value) { NumpyArray<Short> result = NumpyArrayFactory.createArrayOfShapeAndTypeInfo(false, NumpyArrayFactory.SIZE_OF_INT_16, new int[]{1, 1}); result.set(value, 0, 0); return result; } /** * Wraps an atomic byte value into a 2 dimensional array. * * @param value The value to be wrapped into an array. * @return A two dimensional array that wraps the given value. */ public static NumpyArray<Byte> atLeast2D(byte value) { NumpyArray<Byte> result = NumpyArrayFactory.createArrayOfShapeAndTypeInfo(false, NumpyArrayFactory.SIZE_OF_INT_8, new int[]{1, 1}); result.set(value, 0, 0); return result; } /** * Wraps a numpy array into a 2 dimensional array if the number dimensions is less than 2. * * @param array The array to be wrapped into a 2 dimensional array. * @return A two dimensional array that wraps the given value. */ public static <Type> NumpyArray<Type> atLeast2D(NumpyArray<Type> array) { // https://github.com/numpy/numpy/blob/v1.22.0/numpy/core/shape_base.py#L81-L132 NumpyArray<Type> result = null; if (array.numberOfDimensions() == 1) { result = NumpyArrayFactory.createArrayOfShapeAndTypeInfo(array.isFloatingPoint(), array.numberOfBytes(), new int[]{1, array.getShape()[0]}); for (int i = 0; i < array.getShape()[0]; i++) { result.set(array.get(i), 0, i); } } else if (array.numberOfDimensions() > 1) { result = array; } else { throw new NumpyOperationException("The input for atLeast2D is invalid"); } return result; } /** * Returns the maximum values along an axis. * See: https://numpy.org/doc/stable/reference/generated/numpy.amax.html * * @param array The input multidimensional array. * @param axis The axis which the amax should reduce to. * @param keepDimensions A flag to specify whether to keep the reduced dimension in the output. * @return Array of maximum into the array. It has the same shape as a.shape with the dimension along axis removed. */ public static NumpyArray<Double> arrayMax(NumpyArray<Double> array, int axis, boolean keepDimensions) { NumpyArrayOperationWithAxisReduction<Double, Double> operation = new NumpyArrayOperationWithAxisReduction<>() { @Override public NumpyArray<Double> createInstanceResultNumpyArray(int[] shape) { return NumpyArrayFactory.arrayOfDoubleWithShape(shape); } @Override public Object reduceAxisValues(Object[] valuesInAxis) { double max = (double) valuesInAxis[0]; for (int i = 1; i < valuesInAxis.length; i++) { double m = (double) valuesInAxis[i]; if (m > max) { max = m; } } return max; } }; return operation.apply(array, axis, keepDimensions); } /** * Remove axes of length one from the array. * * @param array The array to squeeze. * @return An array without any dimension of length 1. */ public static NumpyArray squeeze(NumpyArray array) { int desiredDimensions = 0; for (int i = 0; i < array.getShape().length; i++) { int dim = array.getShape()[i]; if (dim > 1) { desiredDimensions++; } } int[] shape = new int[desiredDimensions]; int[] mapper = new int[desiredDimensions]; int indexOnShape = 0; for (int i = 0; i < array.getShape().length; i++) { int dim = array.getShape()[i]; if (dim > 1) { shape[indexOnShape] = dim; mapper[indexOnShape] = i; indexOnShape++; } } NumpyArray result = NumpyArrayFactory.createArrayOfShapeAndTypeInfo(array.isFloatingPoint(), array.numberOfBytes(), shape); int[] counter = new int[shape.length + 1]; int[] indexOnInput = new int[array.getShape().length]; do { NumpyArray.addCounter(counter, shape); for (int i = 0; i < mapper.length; i++) { indexOnInput[mapper[i]] = counter[i]; } result.set(array.get(indexOnInput), counter); } while (counter[counter.length - 1] == 0); return result; } /** * Clip (limit) the values in an array. * <p> * Given an interval, values outside the interval are clipped to the interval edges. * For example, if an interval of [0, 1] is specified, values smaller than 0 become 0, * and values larger than 1 become 1. * <p> * Equivalent to but faster than np.minimum(a_max, np.maximum(a, a_min)). * * @param array Array containing elements to clip. * @param min The minimum value to clip. * @param max The maximum value to clip. * @return An array with the elements of array, but where values less than min are replaced * with min, and those greater than max with max. */ public static NumpyArray<Double> clip(NumpyArray<Double> array, double min, double max) { NumpyArray<Double> result = NumpyArrayFactory.createArrayOfShapeAndTypeInfo(array); array.applyToEachElementAnsSaveToTarget(result, value -> { if (value > max) { return max; } else if (value < min) { return min; } return value; }); return result; } /** * Calculate the absolute value element-wise. * * @param array Input array. * @return An ndarray containing the absolute value of each element in x. */ public static NumpyArray abs(NumpyArray<Double> array) { NumpyArray result = NumpyArrayFactory.createArrayOfShapeAndTypeInfo(array); INumpyArrayElementOperation absOperation = null; if (array.isFloatingPoint()) { if (array.numberOfBytes() == NumpyArrayFactory.SIZE_OF_DOUBLE) { absOperation = value -> Math.abs((double) value); } else if (array.numberOfBytes() == NumpyArrayFactory.SIZE_OF_FLOAT) { absOperation = value -> Math.abs((float) value); } } else { if (array.numberOfBytes() == NumpyArrayFactory.SIZE_OF_INT_8) { absOperation = value -> Math.abs((byte) value); } else if (array.numberOfBytes() == NumpyArrayFactory.SIZE_OF_INT_16) { absOperation = value -> Math.abs((short) value); } else if (array.numberOfBytes() == NumpyArrayFactory.SIZE_OF_INT_32) { absOperation = value -> Math.abs((int) value); } else if (array.numberOfBytes() == NumpyArrayFactory.SIZE_OF_INT_64) { absOperation = value -> Math.abs((long) value); } } array.applyToEachElementAnsSaveToTarget(result, absOperation); return result; } /** * Return the non-negative square-root of an array, element-wise. * * @param array The values whose square-roots are required. * @return An array of the same shape as x, containing the positive square-root * of each element in x. */ public static NumpyArray<Double> sqrt(NumpyArray array) { NumpyArray<Double> result = NumpyArrayFactory.createArrayOfShapeAndTypeInfo(true, NumpyArrayFactory.SIZE_OF_DOUBLE, array.getShape()); INumpyArrayElementOperation sqrtOperation = null; if (array.isFloatingPoint()) { if (array.numberOfBytes() == NumpyArrayFactory.SIZE_OF_DOUBLE) { sqrtOperation = value -> Math.sqrt((double) value); } else if (array.numberOfBytes() == NumpyArrayFactory.SIZE_OF_FLOAT) { sqrtOperation = value -> Math.sqrt((float) value); } } else { if (array.numberOfBytes() == NumpyArrayFactory.SIZE_OF_INT_8) { sqrtOperation = value -> Math.sqrt((byte) value); } else if (array.numberOfBytes() == NumpyArrayFactory.SIZE_OF_INT_16) { sqrtOperation = value -> Math.sqrt((short) value); } else if (array.numberOfBytes() == NumpyArrayFactory.SIZE_OF_INT_32) { sqrtOperation = value -> Math.sqrt((int) value); } else if (array.numberOfBytes() == NumpyArrayFactory.SIZE_OF_INT_64) { sqrtOperation = value -> Math.sqrt((long) value); } } array.applyToEachElementAnsSaveToTarget(result, sqrtOperation); return result; } }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy/NumpyArray.java
package ai.sklearn4j.core.libraries.numpy; /** * Provide the functionality of the Numpy arrays and an abstraction over the element types. * * @param <Type> Type of the elements of the array. */ public class NumpyArray<Type> { /** * The internal data of the array. */ private INumpyArrayWrapper data = null; /** * Instantiate a new object of NumpyArray. * * @param data The content of the numpy array. */ protected NumpyArray(INumpyArrayWrapper data) { this.data = data; } /** * Gets the shape of the numpy array. * * @return The array shape. */ public int[] getShape() { return data.getShape(); } /** * Gets an element in the array specified by it index. * * @param indices The index of the element to be retrieved. * @return The element value in the array specified by its index. */ public Type get(int... indices) { if (indices.length != getShape().length) { throw new NumpyOperationException("The number of indices provided doesn't match the number of dimensions."); } return (Type) data.get(indices); } /** * Applies a provided operation on every element of the array and stores it in the * same array. * * @param operation The operation to be applied on the elements. */ public void applyToEachElement(INumpyArrayElementOperation<Type> operation) { int[] shape = data.getShape(); int[] index = new int[shape.length]; int[] counter = new int[shape.length + 1]; counter[0] = -1; do { addCounter(counter, shape); for (int i = 0; i < index.length; i++) { index[i] = counter[i]; } data.set(operation.apply((Type) data.get(index)), index); } while (counter[counter.length - 1] == 0); } /** * Applies a provided operation on every element of the array and stores it in a * specified target array. * * @param target The array that the result should be stored into. * @param operation The operation to be applied on the elements. */ public void applyToEachElementAnsSaveToTarget(NumpyArray target, INumpyArrayElementOperation<Type> operation) { int[] shape = data.getShape(); int[] index = new int[shape.length]; int[] counter = new int[shape.length + 1]; counter[0] = -1; do { addCounter(counter, shape); for (int i = 0; i < index.length; i++) { index[i] = counter[i]; } target.set(operation.apply((Type) data.get(index)), index); } while (counter[counter.length - 1] == 0); } /** * The numpy array could be multidimensional. To iterate over the element given that the * dimension is dynamic, a counter is used. This method increase the value of the counter * to move the index to the next element. * * @param counter The current index. * @param shape The shape of the array. */ public static void addCounter(int[] counter, int[] shape) { counter[0]++; for (int i = 0; i < shape.length; i++) { if (counter[i] == shape[i]) { counter[i] = 0; counter[i + 1]++; } else { break; } } } /** * Sets an element in the array specified by it index. * * @param value The value to be set. * @param indices The index of the element to be modified. */ public void set(Object value, int... indices) { data.set(value, indices); } /** * Returns a boolean indicating if the underlying data type is floating numbers or not. * * @return A boolean indicating if the underlying data type is floating numbers or not. */ public boolean isFloatingPoint() { return data.isFloatingPoint(); } /** * Gets the number of bytes allocated in memory for each element. * * @return Number of bytes allocated in memory for each element. */ public int numberOfBytes() { return data.numberOfBits() / 8; } /** * Transposes an array by reversing the order of its dimensions. * * @return The transposed array. */ public NumpyArray<Type> transpose() { return data.transpose(); } /** * Returns a boolean indicating if the array contains only a single element. * * @return A boolean indicating if the array contains only a single element. */ public boolean isSingleValueArray() { int count = 1; int[] shape = getShape(); for (int i = 0; i < shape.length; i++) { count = count * shape[i]; } return count == 1; } /** * Gets the first element of the numpy array from its memory layout. * * @return The first element of the array. */ public Type getSingleValue() { int[] shape = getShape(); int[] index = new int[shape.length]; return (Type) data.get(index); } /** * Wraps a subset of the numpy array. This methods works only when slicing the most inner dimensions * of the array. For example, if the shape is [2, 6, 4, 8], wrapInnerSubsetArray(1, 3) is equivalent * to numpy array[1, 3, :, :]. * * @param indices The indices of the first dimensions to keep. * @return A new INumpyArrayWrapper wrapping the inner dimensions. This array has the same reference. */ public NumpyArray<Type> wrapInnerSubsetArray(int... indices) { return data.wrapInnerSubsetArray(indices); } /** * Gets the number of dimensions of the numpy array. * * @return */ public int numberOfDimensions() { return getShape().length; } /** * Gets the object that wraps the underlying array. * * @return The object that wraps the underlying array. */ public INumpyArrayWrapper getWrapper() { return data; } /** * Returns a string representation of the array for DEBUGGING purposes. This value should not be * used by external libraries. */ @Override public String toString() { StringBuilder result = new StringBuilder(); result.append("["); String sep = ""; for (int i = 0; i < getShape().length; i++) { result.append(sep); result.append(getShape()[i]); sep = ", "; } result.append("]"); return result.toString(); } }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy/NumpyArrayFactory.java
package ai.sklearn4j.core.libraries.numpy; import ai.sklearn4j.core.libraries.numpy.wrappers.*; /** * A factory class that facilitate the creation of NumpyArrays. */ public class NumpyArrayFactory { /** * Number of bytes used to allocate a byte. */ public static final int SIZE_OF_INT_8 = 1; /** * Number of bytes used to allocate a short. */ public static final int SIZE_OF_INT_16 = 2; /** * Number of bytes used to allocate an int. */ public static final int SIZE_OF_INT_32 = 4; /** * Number of bytes used to allocate a long. */ public static final int SIZE_OF_INT_64 = 8; /** * Number of bytes used to allocate a float. */ public static final int SIZE_OF_FLOAT = 4; /** * Number of bytes used to allocate a double. */ public static final int SIZE_OF_DOUBLE = 8; /** * Creates a numpy array of the same dimension and data type of the provided one. * * @param other The other array to create a similar array to. * @return An empty array with the same shape and data type. */ public static NumpyArray createArrayOfShapeAndTypeInfo(NumpyArray other) { return createArrayOfShapeAndTypeInfo(other.isFloatingPoint(), other.numberOfBytes(), other.getShape()); } /** * Creates a numpy array with a specified shape that can store values with specified * characteristics. * * @param isFloatingPoint Indicates if the elements are floating point. * @param size Indicates the number of bytes each element should allocate in memory. * @param shape Shape of the desired new array. * @return An array of the specified shape and data characteristics. */ public static NumpyArray createArrayOfShapeAndTypeInfo(boolean isFloatingPoint, int size, int[] shape) { NumpyArray result = null; if (isFloatingPoint) { if (size == NumpyArrayFactory.SIZE_OF_DOUBLE) { result = NumpyArrayFactory.arrayOfDoubleWithShape(shape); } else { result = NumpyArrayFactory.arrayOfFloatWithShape(shape); } } else { if (size == NumpyArrayFactory.SIZE_OF_INT_64) { result = NumpyArrayFactory.arrayOfInt64WithShape(shape); } else if (size == NumpyArrayFactory.SIZE_OF_INT_32) { result = NumpyArrayFactory.arrayOfInt32WithShape(shape); } else if (size == NumpyArrayFactory.SIZE_OF_INT_16) { result = NumpyArrayFactory.arrayOfInt16WithShape(shape); } else if (size == NumpyArrayFactory.SIZE_OF_INT_8) { result = NumpyArrayFactory.arrayOfInt8WithShape(shape); } } return result; } /** * Converts a value into a byte. * * @param o The value to be converted. * @return A byte value. */ public static byte toByte(Object o) { byte result = 0; if (o instanceof Byte) { result = (byte) o; } else if (o instanceof Short) { result = (byte) ((short) o); } else if (o instanceof Integer) { result = (byte) ((int) o); } else if (o instanceof Long) { result = (byte) ((long) o); } else { throw new NumpyOperationException("Invalid casting value to byte."); } return result; } /** * Converts a value into a double. * * @param value The value to be converted. * @return A double value. */ public static double toDouble(Object value) { return (double) value; } /** * Converts a value into a float. * * @param value The value to be converted. * @return A float value. */ public static float toFloat(Object value) { return (float) value; } /** * Converts a value into a short. * * @param o The value to be converted. * @return A short value. */ public static short toShort(Object o) { short result = 0; if (o instanceof Byte) { result = (short) o; } else if (o instanceof Short) { result = (short) ((short) o); } else if (o instanceof Integer) { result = (short) ((int) o); } else if (o instanceof Long) { result = (short) ((long) o); } else { throw new NumpyOperationException("Invalid casting value to short."); } return result; } /** * Converts a value into an int. * * @param o The value to be converted. * @return A int value. */ public static int toInteger(Object o) { int result = 0; if (o instanceof Byte) { result = (int) o; } else if (o instanceof Short) { result = (int) ((short) o); } else if (o instanceof Integer) { result = (int) ((int) o); } else if (o instanceof Long) { result = (int) ((long) o); } else { throw new NumpyOperationException("Invalid casting value to int."); } return result; } /** * Converts a value into a long. * * @param o The value to be converted. * @return A long value. */ public static long toLong(Object o) { long result = 0; if (o instanceof Byte) { result = (long) o; } else if (o instanceof Short) { result = (long) ((short) o); } else if (o instanceof Integer) { result = (long) ((int) o); } else if (o instanceof Long) { result = (long) ((long) o); } else { throw new NumpyOperationException("Invalid casting value to long."); } return result; } /** * Create a numpy array wrapper over a 1 dimension byte array. * * @param array The array to be wrapped. * @return The wrapped numpy array. */ public static NumpyArray<Byte> from(byte[] array) { return new NumpyArray<>(new Dim1Int8NumpyWrapper(array)); } /** * Create a numpy array wrapper over a 2 dimension byte array. * * @param array The array to be wrapped. * @return The wrapped numpy array. */ public static NumpyArray<Byte> from(byte[][] array) { return new NumpyArray<>(new Dim2Int8NumpyWrapper(array)); } /** * Create a numpy array wrapper over a 3 dimension byte array. * * @param array The array to be wrapped. * @return The wrapped numpy array. */ public static NumpyArray<Byte> from(byte[][][] array) { return new NumpyArray<>(new Dim3Int8NumpyWrapper(array)); } /** * Create a numpy array wrapper over a 4 dimension byte array. * * @param array The array to be wrapped. * @return The wrapped numpy array. */ public static NumpyArray<Byte> from(byte[][][][] array) { return new NumpyArray<>(new Dim4Int8NumpyWrapper(array)); } /** * Create a numpy array wrapper over a 5 dimension byte array. * * @param array The array to be wrapped. * @return The wrapped numpy array. */ public static NumpyArray<Byte> from(byte[][][][][] array) { return new NumpyArray<>(new Dim5Int8NumpyWrapper(array)); } /** * Create a numpy array wrapper over a 6 dimension byte array. * * @param array The array to be wrapped. * @return The wrapped numpy array. */ public static NumpyArray<Byte> from(byte[][][][][][] array) { return new NumpyArray<>(new Dim6Int8NumpyWrapper(array)); } /** * Create a numpy array wrapper over a 7 dimension byte array. * * @param array The array to be wrapped. * @return The wrapped numpy array. */ public static NumpyArray<Byte> from(byte[][][][][][][] array) { return new NumpyArray<>(new Dim7Int8NumpyWrapper(array)); } /** * Create a numpy array wrapper over a 8 dimension byte array. * * @param array The array to be wrapped. * @return The wrapped numpy array. */ public static NumpyArray<Byte> from(byte[][][][][][][][] array) { return new NumpyArray<>(new Dim8Int8NumpyWrapper(array)); } /** * Create a numpy array wrapper over a 9 dimension byte array. * * @param array The array to be wrapped. * @return The wrapped numpy array. */ public static NumpyArray<Byte> from(byte[][][][][][][][][] array) { return new NumpyArray<>(new Dim9Int8NumpyWrapper(array)); } /** * Create a numpy array wrapper over a 10 dimension byte array. * * @param array The array to be wrapped. * @return The wrapped numpy array. */ public static NumpyArray<Byte> from(byte[][][][][][][][][][] array) { return new NumpyArray<>(new Dim10Int8NumpyWrapper(array)); } /** * Create a numpy array wrapper over a 1 dimension short array. * * @param array The array to be wrapped. * @return The wrapped numpy array. */ public static NumpyArray<Short> from(short[] array) { return new NumpyArray<>(new Dim1Int16NumpyWrapper(array)); } /** * Create a numpy array wrapper over a 2 dimension short array. * * @param array The array to be wrapped. * @return The wrapped numpy array. */ public static NumpyArray<Short> from(short[][] array) { return new NumpyArray<>(new Dim2Int16NumpyWrapper(array)); } /** * Create a numpy array wrapper over a 3 dimension short array. * * @param array The array to be wrapped. * @return The wrapped numpy array. */ public static NumpyArray<Short> from(short[][][] array) { return new NumpyArray<>(new Dim3Int16NumpyWrapper(array)); } /** * Create a numpy array wrapper over a 4 dimension short array. * * @param array The array to be wrapped. * @return The wrapped numpy array. */ public static NumpyArray<Short> from(short[][][][] array) { return new NumpyArray<>(new Dim4Int16NumpyWrapper(array)); } /** * Create a numpy array wrapper over a 5 dimension short array. * * @param array The array to be wrapped. * @return The wrapped numpy array. */ public static NumpyArray<Short> from(short[][][][][] array) { return new NumpyArray<>(new Dim5Int16NumpyWrapper(array)); } /** * Create a numpy array wrapper over a 6 dimension short array. * * @param array The array to be wrapped. * @return The wrapped numpy array. */ public static NumpyArray<Short> from(short[][][][][][] array) { return new NumpyArray<>(new Dim6Int16NumpyWrapper(array)); } /** * Create a numpy array wrapper over a 7 dimension short array. * * @param array The array to be wrapped. * @return The wrapped numpy array. */ public static NumpyArray<Short> from(short[][][][][][][] array) { return new NumpyArray<>(new Dim7Int16NumpyWrapper(array)); } /** * Create a numpy array wrapper over a 8 dimension short array. * * @param array The array to be wrapped. * @return The wrapped numpy array. */ public static NumpyArray<Short> from(short[][][][][][][][] array) { return new NumpyArray<>(new Dim8Int16NumpyWrapper(array)); } /** * Create a numpy array wrapper over a 9 dimension short array. * * @param array The array to be wrapped. * @return The wrapped numpy array. */ public static NumpyArray<Short> from(short[][][][][][][][][] array) { return new NumpyArray<>(new Dim9Int16NumpyWrapper(array)); } /** * Create a numpy array wrapper over a 10 dimension short array. * * @param array The array to be wrapped. * @return The wrapped numpy array. */ public static NumpyArray<Short> from(short[][][][][][][][][][] array) { return new NumpyArray<>(new Dim10Int16NumpyWrapper(array)); } /** * Create a numpy array wrapper over a 1 dimension int array. * * @param array The array to be wrapped. * @return The wrapped numpy array. */ public static NumpyArray<Integer> from(int[] array) { return new NumpyArray<>(new Dim1Int32NumpyWrapper(array)); } /** * Create a numpy array wrapper over a 2 dimension int array. * * @param array The array to be wrapped. * @return The wrapped numpy array. */ public static NumpyArray<Integer> from(int[][] array) { return new NumpyArray<>(new Dim2Int32NumpyWrapper(array)); } /** * Create a numpy array wrapper over a 3 dimension int array. * * @param array The array to be wrapped. * @return The wrapped numpy array. */ public static NumpyArray<Integer> from(int[][][] array) { return new NumpyArray<>(new Dim3Int32NumpyWrapper(array)); } /** * Create a numpy array wrapper over a 4 dimension int array. * * @param array The array to be wrapped. * @return The wrapped numpy array. */ public static NumpyArray<Integer> from(int[][][][] array) { return new NumpyArray<>(new Dim4Int32NumpyWrapper(array)); } /** * Create a numpy array wrapper over a 5 dimension int array. * * @param array The array to be wrapped. * @return The wrapped numpy array. */ public static NumpyArray<Integer> from(int[][][][][] array) { return new NumpyArray<>(new Dim5Int32NumpyWrapper(array)); } /** * Create a numpy array wrapper over a 6 dimension int array. * * @param array The array to be wrapped. * @return The wrapped numpy array. */ public static NumpyArray<Integer> from(int[][][][][][] array) { return new NumpyArray<>(new Dim6Int32NumpyWrapper(array)); } /** * Create a numpy array wrapper over a 7 dimension int array. * * @param array The array to be wrapped. * @return The wrapped numpy array. */ public static NumpyArray<Integer> from(int[][][][][][][] array) { return new NumpyArray<>(new Dim7Int32NumpyWrapper(array)); } /** * Create a numpy array wrapper over a 8 dimension int array. * * @param array The array to be wrapped. * @return The wrapped numpy array. */ public static NumpyArray<Integer> from(int[][][][][][][][] array) { return new NumpyArray<>(new Dim8Int32NumpyWrapper(array)); } /** * Create a numpy array wrapper over a 9 dimension int array. * * @param array The array to be wrapped. * @return The wrapped numpy array. */ public static NumpyArray<Integer> from(int[][][][][][][][][] array) { return new NumpyArray<>(new Dim9Int32NumpyWrapper(array)); } /** * Create a numpy array wrapper over a 10 dimension int array. * * @param array The array to be wrapped. * @return The wrapped numpy array. */ public static NumpyArray<Integer> from(int[][][][][][][][][][] array) { return new NumpyArray<>(new Dim10Int32NumpyWrapper(array)); } /** * Create a numpy array wrapper over a 1 dimension long array. * * @param array The array to be wrapped. * @return The wrapped numpy array. */ public static NumpyArray<Long> from(long[] array) { return new NumpyArray<>(new Dim1Int64NumpyWrapper(array)); } /** * Create a numpy array wrapper over a 2 dimension long array. * * @param array The array to be wrapped. * @return The wrapped numpy array. */ public static NumpyArray<Long> from(long[][] array) { return new NumpyArray<>(new Dim2Int64NumpyWrapper(array)); } /** * Create a numpy array wrapper over a 3 dimension long array. * * @param array The array to be wrapped. * @return The wrapped numpy array. */ public static NumpyArray<Long> from(long[][][] array) { return new NumpyArray<>(new Dim3Int64NumpyWrapper(array)); } /** * Create a numpy array wrapper over a 4 dimension long array. * * @param array The array to be wrapped. * @return The wrapped numpy array. */ public static NumpyArray<Long> from(long[][][][] array) { return new NumpyArray<>(new Dim4Int64NumpyWrapper(array)); } /** * Create a numpy array wrapper over a 5 dimension long array. * * @param array The array to be wrapped. * @return The wrapped numpy array. */ public static NumpyArray<Long> from(long[][][][][] array) { return new NumpyArray<>(new Dim5Int64NumpyWrapper(array)); } /** * Create a numpy array wrapper over a 6 dimension long array. * * @param array The array to be wrapped. * @return The wrapped numpy array. */ public static NumpyArray<Long> from(long[][][][][][] array) { return new NumpyArray<>(new Dim6Int64NumpyWrapper(array)); } /** * Create a numpy array wrapper over a 7 dimension long array. * * @param array The array to be wrapped. * @return The wrapped numpy array. */ public static NumpyArray<Long> from(long[][][][][][][] array) { return new NumpyArray<>(new Dim7Int64NumpyWrapper(array)); } /** * Create a numpy array wrapper over a 8 dimension long array. * * @param array The array to be wrapped. * @return The wrapped numpy array. */ public static NumpyArray<Long> from(long[][][][][][][][] array) { return new NumpyArray<>(new Dim8Int64NumpyWrapper(array)); } /** * Create a numpy array wrapper over a 9 dimension long array. * * @param array The array to be wrapped. * @return The wrapped numpy array. */ public static NumpyArray<Long> from(long[][][][][][][][][] array) { return new NumpyArray<>(new Dim9Int64NumpyWrapper(array)); } /** * Create a numpy array wrapper over a 10 dimension long array. * * @param array The array to be wrapped. * @return The wrapped numpy array. */ public static NumpyArray<Long> from(long[][][][][][][][][][] array) { return new NumpyArray<>(new Dim10Int64NumpyWrapper(array)); } /** * Create a numpy array wrapper over a 1 dimension float array. * * @param array The array to be wrapped. * @return The wrapped numpy array. */ public static NumpyArray<Float> from(float[] array) { return new NumpyArray<>(new Dim1FloatNumpyWrapper(array)); } /** * Create a numpy array wrapper over a 2 dimension float array. * * @param array The array to be wrapped. * @return The wrapped numpy array. */ public static NumpyArray<Float> from(float[][] array) { return new NumpyArray<>(new Dim2FloatNumpyWrapper(array)); } /** * Create a numpy array wrapper over a 3 dimension float array. * * @param array The array to be wrapped. * @return The wrapped numpy array. */ public static NumpyArray<Float> from(float[][][] array) { return new NumpyArray<>(new Dim3FloatNumpyWrapper(array)); } /** * Create a numpy array wrapper over a 4 dimension float array. * * @param array The array to be wrapped. * @return The wrapped numpy array. */ public static NumpyArray<Float> from(float[][][][] array) { return new NumpyArray<>(new Dim4FloatNumpyWrapper(array)); } /** * Create a numpy array wrapper over a 5 dimension float array. * * @param array The array to be wrapped. * @return The wrapped numpy array. */ public static NumpyArray<Float> from(float[][][][][] array) { return new NumpyArray<>(new Dim5FloatNumpyWrapper(array)); } /** * Create a numpy array wrapper over a 6 dimension float array. * * @param array The array to be wrapped. * @return The wrapped numpy array. */ public static NumpyArray<Float> from(float[][][][][][] array) { return new NumpyArray<>(new Dim6FloatNumpyWrapper(array)); } /** * Create a numpy array wrapper over a 7 dimension float array. * * @param array The array to be wrapped. * @return The wrapped numpy array. */ public static NumpyArray<Float> from(float[][][][][][][] array) { return new NumpyArray<>(new Dim7FloatNumpyWrapper(array)); } /** * Create a numpy array wrapper over a 8 dimension float array. * * @param array The array to be wrapped. * @return The wrapped numpy array. */ public static NumpyArray<Float> from(float[][][][][][][][] array) { return new NumpyArray<>(new Dim8FloatNumpyWrapper(array)); } /** * Create a numpy array wrapper over a 9 dimension float array. * * @param array The array to be wrapped. * @return The wrapped numpy array. */ public static NumpyArray<Float> from(float[][][][][][][][][] array) { return new NumpyArray<>(new Dim9FloatNumpyWrapper(array)); } /** * Create a numpy array wrapper over a 10 dimension float array. * * @param array The array to be wrapped. * @return The wrapped numpy array. */ public static NumpyArray<Float> from(float[][][][][][][][][][] array) { return new NumpyArray<>(new Dim10FloatNumpyWrapper(array)); } /** * Create a numpy array wrapper over a 1 dimension double array. * * @param array The array to be wrapped. * @return The wrapped numpy array. */ public static NumpyArray<Double> from(double[] array) { return new NumpyArray<>(new Dim1DoubleNumpyWrapper(array)); } /** * Create a numpy array wrapper over a 2 dimension double array. * * @param array The array to be wrapped. * @return The wrapped numpy array. */ public static NumpyArray<Double> from(double[][] array) { return new NumpyArray<>(new Dim2DoubleNumpyWrapper(array)); } /** * Create a numpy array wrapper over a 3 dimension double array. * * @param array The array to be wrapped. * @return The wrapped numpy array. */ public static NumpyArray<Double> from(double[][][] array) { return new NumpyArray<>(new Dim3DoubleNumpyWrapper(array)); } /** * Create a numpy array wrapper over a 4 dimension double array. * * @param array The array to be wrapped. * @return The wrapped numpy array. */ public static NumpyArray<Double> from(double[][][][] array) { return new NumpyArray<>(new Dim4DoubleNumpyWrapper(array)); } /** * Create a numpy array wrapper over a 5 dimension double array. * * @param array The array to be wrapped. * @return The wrapped numpy array. */ public static NumpyArray<Double> from(double[][][][][] array) { return new NumpyArray<>(new Dim5DoubleNumpyWrapper(array)); } /** * Create a numpy array wrapper over a 6 dimension double array. * * @param array The array to be wrapped. * @return The wrapped numpy array. */ public static NumpyArray<Double> from(double[][][][][][] array) { return new NumpyArray<>(new Dim6DoubleNumpyWrapper(array)); } /** * Create a numpy array wrapper over a 7 dimension double array. * * @param array The array to be wrapped. * @return The wrapped numpy array. */ public static NumpyArray<Double> from(double[][][][][][][] array) { return new NumpyArray<>(new Dim7DoubleNumpyWrapper(array)); } /** * Create a numpy array wrapper over a 8 dimension double array. * * @param array The array to be wrapped. * @return The wrapped numpy array. */ public static NumpyArray<Double> from(double[][][][][][][][] array) { return new NumpyArray<>(new Dim8DoubleNumpyWrapper(array)); } /** * Create a numpy array wrapper over a 9 dimension double array. * * @param array The array to be wrapped. * @return The wrapped numpy array. */ public static NumpyArray<Double> from(double[][][][][][][][][] array) { return new NumpyArray<>(new Dim9DoubleNumpyWrapper(array)); } /** * Create a numpy array wrapper over a 10 dimension double array. * * @param array The array to be wrapped. * @return The wrapped numpy array. */ public static NumpyArray<Double> from(double[][][][][][][][][][] array) { return new NumpyArray<>(new Dim10DoubleNumpyWrapper(array)); } /** * Create a numpy array of byte with specified shape. * * @param shape The shape of the new array. * @return The new numpy array with desired shape. */ public static NumpyArray<Byte> arrayOfInt8WithShape(int[] shape) { if (shape.length == 1) { return from(new byte[shape[0]]); } else if (shape.length == 2) { return from(new byte[shape[0]][shape[1]]); } else if (shape.length == 3) { return from(new byte[shape[0]][shape[1]][shape[2]]); } else if (shape.length == 4) { return from(new byte[shape[0]][shape[1]][shape[2]][shape[3]]); } else if (shape.length == 5) { return from(new byte[shape[0]][shape[1]][shape[2]][shape[3]][shape[4]]); } else if (shape.length == 6) { return from(new byte[shape[0]][shape[1]][shape[2]][shape[3]][shape[4]][shape[5]]); } else if (shape.length == 7) { return from(new byte[shape[0]][shape[1]][shape[2]][shape[3]][shape[4]][shape[5]][shape[6]]); } else if (shape.length == 8) { return from(new byte[shape[0]][shape[1]][shape[2]][shape[3]][shape[4]][shape[5]][shape[6]][shape[7]]); } else if (shape.length == 9) { return from(new byte[shape[0]][shape[1]][shape[2]][shape[3]][shape[4]][shape[5]][shape[6]][shape[7]][shape[8]]); } else if (shape.length == 10) { return from(new byte[shape[0]][shape[1]][shape[2]][shape[3]][shape[4]][shape[5]][shape[6]][shape[7]][shape[8]][shape[9]]); } throw new NumpyOperationException("The shape specified is not supported; only arrays less than 10 dimensions are supported."); } /** * Create a numpy array of short with specified shape. * * @param shape The shape of the new array. * @return The new numpy array with desired shape. */ public static NumpyArray<Short> arrayOfInt16WithShape(int[] shape) { if (shape.length == 1) { return from(new short[shape[0]]); } else if (shape.length == 2) { return from(new short[shape[0]][shape[1]]); } else if (shape.length == 3) { return from(new short[shape[0]][shape[1]][shape[2]]); } else if (shape.length == 4) { return from(new short[shape[0]][shape[1]][shape[2]][shape[3]]); } else if (shape.length == 5) { return from(new short[shape[0]][shape[1]][shape[2]][shape[3]][shape[4]]); } else if (shape.length == 6) { return from(new short[shape[0]][shape[1]][shape[2]][shape[3]][shape[4]][shape[5]]); } else if (shape.length == 7) { return from(new short[shape[0]][shape[1]][shape[2]][shape[3]][shape[4]][shape[5]][shape[6]]); } else if (shape.length == 8) { return from(new short[shape[0]][shape[1]][shape[2]][shape[3]][shape[4]][shape[5]][shape[6]][shape[7]]); } else if (shape.length == 9) { return from(new short[shape[0]][shape[1]][shape[2]][shape[3]][shape[4]][shape[5]][shape[6]][shape[7]][shape[8]]); } else if (shape.length == 10) { return from(new short[shape[0]][shape[1]][shape[2]][shape[3]][shape[4]][shape[5]][shape[6]][shape[7]][shape[8]][shape[9]]); } throw new NumpyOperationException("The shape specified is not supported; only arrays less than 10 dimensions are supported."); } /** * Create a numpy array of int with specified shape. * * @param shape The shape of the new array. * @return The new numpy array with desired shape. */ public static NumpyArray<Integer> arrayOfInt32WithShape(int[] shape) { if (shape.length == 1) { return from(new int[shape[0]]); } else if (shape.length == 2) { return from(new int[shape[0]][shape[1]]); } else if (shape.length == 3) { return from(new int[shape[0]][shape[1]][shape[2]]); } else if (shape.length == 4) { return from(new int[shape[0]][shape[1]][shape[2]][shape[3]]); } else if (shape.length == 5) { return from(new int[shape[0]][shape[1]][shape[2]][shape[3]][shape[4]]); } else if (shape.length == 6) { return from(new int[shape[0]][shape[1]][shape[2]][shape[3]][shape[4]][shape[5]]); } else if (shape.length == 7) { return from(new int[shape[0]][shape[1]][shape[2]][shape[3]][shape[4]][shape[5]][shape[6]]); } else if (shape.length == 8) { return from(new int[shape[0]][shape[1]][shape[2]][shape[3]][shape[4]][shape[5]][shape[6]][shape[7]]); } else if (shape.length == 9) { return from(new int[shape[0]][shape[1]][shape[2]][shape[3]][shape[4]][shape[5]][shape[6]][shape[7]][shape[8]]); } else if (shape.length == 10) { return from(new int[shape[0]][shape[1]][shape[2]][shape[3]][shape[4]][shape[5]][shape[6]][shape[7]][shape[8]][shape[9]]); } throw new NumpyOperationException("The shape specified is not supported; only arrays less than 10 dimensions are supported."); } /** * Create a numpy array of long with specified shape. * * @param shape The shape of the new array. * @return The new numpy array with desired shape. */ public static NumpyArray<Long> arrayOfInt64WithShape(int[] shape) { if (shape.length == 1) { return from(new long[shape[0]]); } else if (shape.length == 2) { return from(new long[shape[0]][shape[1]]); } else if (shape.length == 3) { return from(new long[shape[0]][shape[1]][shape[2]]); } else if (shape.length == 4) { return from(new long[shape[0]][shape[1]][shape[2]][shape[3]]); } else if (shape.length == 5) { return from(new long[shape[0]][shape[1]][shape[2]][shape[3]][shape[4]]); } else if (shape.length == 6) { return from(new long[shape[0]][shape[1]][shape[2]][shape[3]][shape[4]][shape[5]]); } else if (shape.length == 7) { return from(new long[shape[0]][shape[1]][shape[2]][shape[3]][shape[4]][shape[5]][shape[6]]); } else if (shape.length == 8) { return from(new long[shape[0]][shape[1]][shape[2]][shape[3]][shape[4]][shape[5]][shape[6]][shape[7]]); } else if (shape.length == 9) { return from(new long[shape[0]][shape[1]][shape[2]][shape[3]][shape[4]][shape[5]][shape[6]][shape[7]][shape[8]]); } else if (shape.length == 10) { return from(new long[shape[0]][shape[1]][shape[2]][shape[3]][shape[4]][shape[5]][shape[6]][shape[7]][shape[8]][shape[9]]); } throw new NumpyOperationException("The shape specified is not supported; only arrays less than 10 dimensions are supported."); } /** * Create a numpy array of float with specified shape. * * @param shape The shape of the new array. * @return The new numpy array with desired shape. */ public static NumpyArray<Float> arrayOfFloatWithShape(int[] shape) { if (shape.length == 1) { return from(new float[shape[0]]); } else if (shape.length == 2) { return from(new float[shape[0]][shape[1]]); } else if (shape.length == 3) { return from(new float[shape[0]][shape[1]][shape[2]]); } else if (shape.length == 4) { return from(new float[shape[0]][shape[1]][shape[2]][shape[3]]); } else if (shape.length == 5) { return from(new float[shape[0]][shape[1]][shape[2]][shape[3]][shape[4]]); } else if (shape.length == 6) { return from(new float[shape[0]][shape[1]][shape[2]][shape[3]][shape[4]][shape[5]]); } else if (shape.length == 7) { return from(new float[shape[0]][shape[1]][shape[2]][shape[3]][shape[4]][shape[5]][shape[6]]); } else if (shape.length == 8) { return from(new float[shape[0]][shape[1]][shape[2]][shape[3]][shape[4]][shape[5]][shape[6]][shape[7]]); } else if (shape.length == 9) { return from(new float[shape[0]][shape[1]][shape[2]][shape[3]][shape[4]][shape[5]][shape[6]][shape[7]][shape[8]]); } else if (shape.length == 10) { return from(new float[shape[0]][shape[1]][shape[2]][shape[3]][shape[4]][shape[5]][shape[6]][shape[7]][shape[8]][shape[9]]); } throw new NumpyOperationException("The shape specified is not supported; only arrays less than 10 dimensions are supported."); } /** * Create a numpy array of double with specified shape. * * @param shape The shape of the new array. * @return The new numpy array with desired shape. */ public static NumpyArray<Double> arrayOfDoubleWithShape(int[] shape) { if (shape.length == 1) { return from(new double[shape[0]]); } else if (shape.length == 2) { return from(new double[shape[0]][shape[1]]); } else if (shape.length == 3) { return from(new double[shape[0]][shape[1]][shape[2]]); } else if (shape.length == 4) { return from(new double[shape[0]][shape[1]][shape[2]][shape[3]]); } else if (shape.length == 5) { return from(new double[shape[0]][shape[1]][shape[2]][shape[3]][shape[4]]); } else if (shape.length == 6) { return from(new double[shape[0]][shape[1]][shape[2]][shape[3]][shape[4]][shape[5]]); } else if (shape.length == 7) { return from(new double[shape[0]][shape[1]][shape[2]][shape[3]][shape[4]][shape[5]][shape[6]]); } else if (shape.length == 8) { return from(new double[shape[0]][shape[1]][shape[2]][shape[3]][shape[4]][shape[5]][shape[6]][shape[7]]); } else if (shape.length == 9) { return from(new double[shape[0]][shape[1]][shape[2]][shape[3]][shape[4]][shape[5]][shape[6]][shape[7]][shape[8]]); } else if (shape.length == 10) { return from(new double[shape[0]][shape[1]][shape[2]][shape[3]][shape[4]][shape[5]][shape[6]][shape[7]][shape[8]][shape[9]]); } throw new NumpyOperationException("The shape specified is not supported; only arrays less than 10 dimensions are supported."); } }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy/NumpyArrayOperationWithAxisReduction.java
package ai.sklearn4j.core.libraries.numpy; /** * Base class for all the operations that performs an aggregation and reduction on a given * NumpyArray. * * @param <InputType> The element type of the input numpy array. * @param <OutputType> The element type of the output numpy array. */ public abstract class NumpyArrayOperationWithAxisReduction<InputType, OutputType> { /** * The input numpy array to perform the operation on. */ private NumpyArray<InputType> array; /** * Applies the operation on the numpy array. * * @param array Input array to perform operation on. * @param axis The axis that should be reduced on. * @param keepDimensions A flag indicating to keep the same number of dimension as the input. * @return The numpy array that contains the result of the reduction. */ public NumpyArray<OutputType> apply(NumpyArray<InputType> array, int axis, boolean keepDimensions) { this.array = array; int[] inputShape = array.getShape(); int countInAxis = inputShape[axis]; int[] outputShape = getOutShape(axis, inputShape, false); int[] outputShapeWithKeepDimensions = getOutShape(axis, inputShape, keepDimensions); NumpyArray<OutputType> result = createInstanceResultNumpyArray(outputShapeWithKeepDimensions); int[] counter = new int[outputShape.length + 1]; counter[0] = -1; int[] outputCounter = new int[outputShapeWithKeepDimensions.length + 1]; outputCounter[0] = -1; do { NumpyArray.addCounter(counter, outputShape); NumpyArray.addCounter(outputCounter, outputShapeWithKeepDimensions); int[] indexOnInput = new int[inputShape.length]; int temp = 0; for (int i = 0; i < indexOnInput.length; i++) { if (i != axis) { indexOnInput[i] = counter[temp]; temp++; } } Object[] valuesInAxis = new Object[countInAxis]; for (int i = 0; i < countInAxis; i++) { indexOnInput[axis] = i; valuesInAxis[i] = array.get(indexOnInput); } result.set(reduceAxisValues(valuesInAxis), outputCounter); } while (counter[counter.length - 1] == 0); return result; } /** * Calculate the shape of the output array. * * @param axis The axis to reduce on. * @param inputShape The shape of the input array. * @param keepDimensions A boolean indicating to keep the original number of dimensions. * @return The shape of the output based on the parameters. */ private int[] getOutShape(int axis, int[] inputShape, boolean keepDimensions) { int offset = keepDimensions ? 0 : 1; int[] outputShape = new int[inputShape.length - offset]; int temp = 0; for (int i = 0; i < inputShape.length; i++) { if (i != axis) { outputShape[temp] = inputShape[i]; temp++; } else if (keepDimensions) { outputShape[temp] = 1; temp++; } } return outputShape; } /** * Instantiate the result numpy array. * * @param shape The shape of the desired array. * @return An empty array with the desired specifications. */ public NumpyArray<OutputType> createInstanceResultNumpyArray(int[] shape) { int size = array.numberOfBytes(); boolean isFloatingPoint = array.isFloatingPoint(); return (NumpyArray<OutputType>) NumpyArrayFactory.createArrayOfShapeAndTypeInfo(isFloatingPoint, size, shape); } /** * The core operation that does the aggregation. * * @param valuesInAxis The elements of the specified axis. * @return The aggregated value. */ public abstract Object reduceAxisValues(Object[] valuesInAxis); }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy/NumpyOperationException.java
package ai.sklearn4j.core.libraries.numpy; /** * A custom exception that provides information on what went wrong in numpy's processing. */ public class NumpyOperationException extends RuntimeException { /** * Instantiate a new exception object. * * @param message The content of the error. */ public NumpyOperationException(String message) { super(message); } }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy/wrappers/Dim10DoubleNumpyWrapper.java
/* * This file was automatically generated, don't edit it manually. */ package ai.sklearn4j.core.libraries.numpy.wrappers; import ai.sklearn4j.core.libraries.numpy.INumpyArrayWrapper; import ai.sklearn4j.core.libraries.numpy.NumpyArray; import ai.sklearn4j.core.libraries.numpy.NumpyArrayFactory; import ai.sklearn4j.core.libraries.numpy.NumpyOperationException; /** * A wrapper over a 10 dimensions double array for NumpyArray class. */ public class Dim10DoubleNumpyWrapper implements INumpyArrayWrapper { private final double[][][][][][][][][][] array; private final int[] shape; /** * Instantiate a new wrapper for 10 array. * * @param array The underlying native array object. */ public Dim10DoubleNumpyWrapper(double[][][][][][][][][][] array) { this.array = array; this.shape = new int[]{array.length, array[0].length, array[0][0].length, array[0][0][0].length, array[0][0][0][0].length, array[0][0][0][0][0].length, array[0][0][0][0][0][0].length, array[0][0][0][0][0][0][0].length, array[0][0][0][0][0][0][0][0].length, array[0][0][0][0][0][0][0][0][0].length}; } @Override public int[] getShape() { return shape; } @Override public Object get(int... indices) { return array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]][indices[7]][indices[8]][indices[9]]; } @Override public void set(Object value, int... indices) { this.array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]][indices[7]][indices[8]][indices[9]] = NumpyArrayFactory.toDouble(value); } /** * Gets the underlying native array object. * * @return The underlying native array object. */ public double[][][][][][][][][][] getArray() { return this.array; } @Override public boolean isFloatingPoint() { return true; } @Override public int numberOfBits() { return 64; } @Override public Object getRawArray() { return array; } @Override public NumpyArray wrapInnerSubsetArray(int... indices) { NumpyArray result = null; if (indices.length == 1) { result = NumpyArrayFactory.from(array[indices[0]]); } else if (indices.length == 2) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]]); } else if (indices.length == 3) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]]); } else if (indices.length == 4) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]]); } else if (indices.length == 5) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]]); } else if (indices.length == 6) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]]); } else if (indices.length == 7) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]]); } else if (indices.length == 8) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]][indices[7]]); } else if (indices.length == 9) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]][indices[7]][indices[8]]); } else { throw new NumpyOperationException("Invalid slice for array specified."); } return result; } @Override public NumpyArray transpose() { double[][][][][][][][][][] result = new double[shape[9]][shape[8]][shape[7]][shape[6]][shape[5]][shape[4]][shape[3]][shape[2]][shape[1]][shape[0]]; for (int d0 = 0; d0 < this.shape[0]; d0++) { for (int d1 = 0; d1 < this.shape[1]; d1++) { for (int d2 = 0; d2 < this.shape[2]; d2++) { for (int d3 = 0; d3 < this.shape[3]; d3++) { for (int d4 = 0; d4 < this.shape[4]; d4++) { for (int d5 = 0; d5 < this.shape[5]; d5++) { for (int d6 = 0; d6 < this.shape[6]; d6++) { for (int d7 = 0; d7 < this.shape[7]; d7++) { for (int d8 = 0; d8 < this.shape[8]; d8++) { for (int d9 = 0; d9 < this.shape[9]; d9++) { result[d9][d8][d7][d6][d5][d4][d3][d2][d1][d0] = array[d0][d1][d2][d3][d4][d5][d6][d7][d8][d9]; } } } } } } } } } } return NumpyArrayFactory.from(result); } }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy/wrappers/Dim10FloatNumpyWrapper.java
/* * This file was automatically generated, don't edit it manually. */ package ai.sklearn4j.core.libraries.numpy.wrappers; import ai.sklearn4j.core.libraries.numpy.INumpyArrayWrapper; import ai.sklearn4j.core.libraries.numpy.NumpyArray; import ai.sklearn4j.core.libraries.numpy.NumpyArrayFactory; import ai.sklearn4j.core.libraries.numpy.NumpyOperationException; /** * A wrapper over a 10 dimensions float array for NumpyArray class. */ public class Dim10FloatNumpyWrapper implements INumpyArrayWrapper { private final float[][][][][][][][][][] array; private final int[] shape; /** * Instantiate a new wrapper for 10 array. * * @param array The underlying native array object. */ public Dim10FloatNumpyWrapper(float[][][][][][][][][][] array) { this.array = array; this.shape = new int[]{array.length, array[0].length, array[0][0].length, array[0][0][0].length, array[0][0][0][0].length, array[0][0][0][0][0].length, array[0][0][0][0][0][0].length, array[0][0][0][0][0][0][0].length, array[0][0][0][0][0][0][0][0].length, array[0][0][0][0][0][0][0][0][0].length}; } @Override public int[] getShape() { return shape; } @Override public Object get(int... indices) { return array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]][indices[7]][indices[8]][indices[9]]; } @Override public void set(Object value, int... indices) { this.array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]][indices[7]][indices[8]][indices[9]] = NumpyArrayFactory.toFloat(value); } /** * Gets the underlying native array object. * * @return The underlying native array object. */ public float[][][][][][][][][][] getArray() { return this.array; } @Override public boolean isFloatingPoint() { return true; } @Override public int numberOfBits() { return 32; } @Override public Object getRawArray() { return array; } @Override public NumpyArray wrapInnerSubsetArray(int... indices) { NumpyArray result = null; if (indices.length == 1) { result = NumpyArrayFactory.from(array[indices[0]]); } else if (indices.length == 2) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]]); } else if (indices.length == 3) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]]); } else if (indices.length == 4) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]]); } else if (indices.length == 5) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]]); } else if (indices.length == 6) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]]); } else if (indices.length == 7) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]]); } else if (indices.length == 8) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]][indices[7]]); } else if (indices.length == 9) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]][indices[7]][indices[8]]); } else { throw new NumpyOperationException("Invalid slice for array specified."); } return result; } @Override public NumpyArray transpose() { float[][][][][][][][][][] result = new float[shape[9]][shape[8]][shape[7]][shape[6]][shape[5]][shape[4]][shape[3]][shape[2]][shape[1]][shape[0]]; for (int d0 = 0; d0 < this.shape[0]; d0++) { for (int d1 = 0; d1 < this.shape[1]; d1++) { for (int d2 = 0; d2 < this.shape[2]; d2++) { for (int d3 = 0; d3 < this.shape[3]; d3++) { for (int d4 = 0; d4 < this.shape[4]; d4++) { for (int d5 = 0; d5 < this.shape[5]; d5++) { for (int d6 = 0; d6 < this.shape[6]; d6++) { for (int d7 = 0; d7 < this.shape[7]; d7++) { for (int d8 = 0; d8 < this.shape[8]; d8++) { for (int d9 = 0; d9 < this.shape[9]; d9++) { result[d9][d8][d7][d6][d5][d4][d3][d2][d1][d0] = array[d0][d1][d2][d3][d4][d5][d6][d7][d8][d9]; } } } } } } } } } } return NumpyArrayFactory.from(result); } }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy/wrappers/Dim10Int16NumpyWrapper.java
/* * This file was automatically generated, don't edit it manually. */ package ai.sklearn4j.core.libraries.numpy.wrappers; import ai.sklearn4j.core.libraries.numpy.INumpyArrayWrapper; import ai.sklearn4j.core.libraries.numpy.NumpyArray; import ai.sklearn4j.core.libraries.numpy.NumpyArrayFactory; import ai.sklearn4j.core.libraries.numpy.NumpyOperationException; /** * A wrapper over a 10 dimensions short array for NumpyArray class. */ public class Dim10Int16NumpyWrapper implements INumpyArrayWrapper { private final short[][][][][][][][][][] array; private final int[] shape; /** * Instantiate a new wrapper for 10 array. * * @param array The underlying native array object. */ public Dim10Int16NumpyWrapper(short[][][][][][][][][][] array) { this.array = array; this.shape = new int[]{array.length, array[0].length, array[0][0].length, array[0][0][0].length, array[0][0][0][0].length, array[0][0][0][0][0].length, array[0][0][0][0][0][0].length, array[0][0][0][0][0][0][0].length, array[0][0][0][0][0][0][0][0].length, array[0][0][0][0][0][0][0][0][0].length}; } @Override public int[] getShape() { return shape; } @Override public Object get(int... indices) { return array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]][indices[7]][indices[8]][indices[9]]; } @Override public void set(Object value, int... indices) { this.array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]][indices[7]][indices[8]][indices[9]] = NumpyArrayFactory.toShort(value); } /** * Gets the underlying native array object. * * @return The underlying native array object. */ public short[][][][][][][][][][] getArray() { return this.array; } @Override public boolean isFloatingPoint() { return false; } @Override public int numberOfBits() { return 16; } @Override public Object getRawArray() { return array; } @Override public NumpyArray wrapInnerSubsetArray(int... indices) { NumpyArray result = null; if (indices.length == 1) { result = NumpyArrayFactory.from(array[indices[0]]); } else if (indices.length == 2) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]]); } else if (indices.length == 3) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]]); } else if (indices.length == 4) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]]); } else if (indices.length == 5) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]]); } else if (indices.length == 6) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]]); } else if (indices.length == 7) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]]); } else if (indices.length == 8) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]][indices[7]]); } else if (indices.length == 9) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]][indices[7]][indices[8]]); } else { throw new NumpyOperationException("Invalid slice for array specified."); } return result; } @Override public NumpyArray transpose() { short[][][][][][][][][][] result = new short[shape[9]][shape[8]][shape[7]][shape[6]][shape[5]][shape[4]][shape[3]][shape[2]][shape[1]][shape[0]]; for (int d0 = 0; d0 < this.shape[0]; d0++) { for (int d1 = 0; d1 < this.shape[1]; d1++) { for (int d2 = 0; d2 < this.shape[2]; d2++) { for (int d3 = 0; d3 < this.shape[3]; d3++) { for (int d4 = 0; d4 < this.shape[4]; d4++) { for (int d5 = 0; d5 < this.shape[5]; d5++) { for (int d6 = 0; d6 < this.shape[6]; d6++) { for (int d7 = 0; d7 < this.shape[7]; d7++) { for (int d8 = 0; d8 < this.shape[8]; d8++) { for (int d9 = 0; d9 < this.shape[9]; d9++) { result[d9][d8][d7][d6][d5][d4][d3][d2][d1][d0] = array[d0][d1][d2][d3][d4][d5][d6][d7][d8][d9]; } } } } } } } } } } return NumpyArrayFactory.from(result); } }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy/wrappers/Dim10Int32NumpyWrapper.java
/* * This file was automatically generated, don't edit it manually. */ package ai.sklearn4j.core.libraries.numpy.wrappers; import ai.sklearn4j.core.libraries.numpy.INumpyArrayWrapper; import ai.sklearn4j.core.libraries.numpy.NumpyArray; import ai.sklearn4j.core.libraries.numpy.NumpyArrayFactory; import ai.sklearn4j.core.libraries.numpy.NumpyOperationException; /** * A wrapper over a 10 dimensions int array for NumpyArray class. */ public class Dim10Int32NumpyWrapper implements INumpyArrayWrapper { private final int[][][][][][][][][][] array; private final int[] shape; /** * Instantiate a new wrapper for 10 array. * * @param array The underlying native array object. */ public Dim10Int32NumpyWrapper(int[][][][][][][][][][] array) { this.array = array; this.shape = new int[]{array.length, array[0].length, array[0][0].length, array[0][0][0].length, array[0][0][0][0].length, array[0][0][0][0][0].length, array[0][0][0][0][0][0].length, array[0][0][0][0][0][0][0].length, array[0][0][0][0][0][0][0][0].length, array[0][0][0][0][0][0][0][0][0].length}; } @Override public int[] getShape() { return shape; } @Override public Object get(int... indices) { return array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]][indices[7]][indices[8]][indices[9]]; } @Override public void set(Object value, int... indices) { this.array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]][indices[7]][indices[8]][indices[9]] = NumpyArrayFactory.toInteger(value); } /** * Gets the underlying native array object. * * @return The underlying native array object. */ public int[][][][][][][][][][] getArray() { return this.array; } @Override public boolean isFloatingPoint() { return false; } @Override public int numberOfBits() { return 32; } @Override public Object getRawArray() { return array; } @Override public NumpyArray wrapInnerSubsetArray(int... indices) { NumpyArray result = null; if (indices.length == 1) { result = NumpyArrayFactory.from(array[indices[0]]); } else if (indices.length == 2) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]]); } else if (indices.length == 3) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]]); } else if (indices.length == 4) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]]); } else if (indices.length == 5) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]]); } else if (indices.length == 6) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]]); } else if (indices.length == 7) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]]); } else if (indices.length == 8) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]][indices[7]]); } else if (indices.length == 9) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]][indices[7]][indices[8]]); } else { throw new NumpyOperationException("Invalid slice for array specified."); } return result; } @Override public NumpyArray transpose() { int[][][][][][][][][][] result = new int[shape[9]][shape[8]][shape[7]][shape[6]][shape[5]][shape[4]][shape[3]][shape[2]][shape[1]][shape[0]]; for (int d0 = 0; d0 < this.shape[0]; d0++) { for (int d1 = 0; d1 < this.shape[1]; d1++) { for (int d2 = 0; d2 < this.shape[2]; d2++) { for (int d3 = 0; d3 < this.shape[3]; d3++) { for (int d4 = 0; d4 < this.shape[4]; d4++) { for (int d5 = 0; d5 < this.shape[5]; d5++) { for (int d6 = 0; d6 < this.shape[6]; d6++) { for (int d7 = 0; d7 < this.shape[7]; d7++) { for (int d8 = 0; d8 < this.shape[8]; d8++) { for (int d9 = 0; d9 < this.shape[9]; d9++) { result[d9][d8][d7][d6][d5][d4][d3][d2][d1][d0] = array[d0][d1][d2][d3][d4][d5][d6][d7][d8][d9]; } } } } } } } } } } return NumpyArrayFactory.from(result); } }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy/wrappers/Dim10Int64NumpyWrapper.java
/* * This file was automatically generated, don't edit it manually. */ package ai.sklearn4j.core.libraries.numpy.wrappers; import ai.sklearn4j.core.libraries.numpy.INumpyArrayWrapper; import ai.sklearn4j.core.libraries.numpy.NumpyArray; import ai.sklearn4j.core.libraries.numpy.NumpyArrayFactory; import ai.sklearn4j.core.libraries.numpy.NumpyOperationException; /** * A wrapper over a 10 dimensions long array for NumpyArray class. */ public class Dim10Int64NumpyWrapper implements INumpyArrayWrapper { private final long[][][][][][][][][][] array; private final int[] shape; /** * Instantiate a new wrapper for 10 array. * * @param array The underlying native array object. */ public Dim10Int64NumpyWrapper(long[][][][][][][][][][] array) { this.array = array; this.shape = new int[]{array.length, array[0].length, array[0][0].length, array[0][0][0].length, array[0][0][0][0].length, array[0][0][0][0][0].length, array[0][0][0][0][0][0].length, array[0][0][0][0][0][0][0].length, array[0][0][0][0][0][0][0][0].length, array[0][0][0][0][0][0][0][0][0].length}; } @Override public int[] getShape() { return shape; } @Override public Object get(int... indices) { return array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]][indices[7]][indices[8]][indices[9]]; } @Override public void set(Object value, int... indices) { this.array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]][indices[7]][indices[8]][indices[9]] = NumpyArrayFactory.toLong(value); } /** * Gets the underlying native array object. * * @return The underlying native array object. */ public long[][][][][][][][][][] getArray() { return this.array; } @Override public boolean isFloatingPoint() { return false; } @Override public int numberOfBits() { return 64; } @Override public Object getRawArray() { return array; } @Override public NumpyArray wrapInnerSubsetArray(int... indices) { NumpyArray result = null; if (indices.length == 1) { result = NumpyArrayFactory.from(array[indices[0]]); } else if (indices.length == 2) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]]); } else if (indices.length == 3) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]]); } else if (indices.length == 4) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]]); } else if (indices.length == 5) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]]); } else if (indices.length == 6) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]]); } else if (indices.length == 7) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]]); } else if (indices.length == 8) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]][indices[7]]); } else if (indices.length == 9) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]][indices[7]][indices[8]]); } else { throw new NumpyOperationException("Invalid slice for array specified."); } return result; } @Override public NumpyArray transpose() { long[][][][][][][][][][] result = new long[shape[9]][shape[8]][shape[7]][shape[6]][shape[5]][shape[4]][shape[3]][shape[2]][shape[1]][shape[0]]; for (int d0 = 0; d0 < this.shape[0]; d0++) { for (int d1 = 0; d1 < this.shape[1]; d1++) { for (int d2 = 0; d2 < this.shape[2]; d2++) { for (int d3 = 0; d3 < this.shape[3]; d3++) { for (int d4 = 0; d4 < this.shape[4]; d4++) { for (int d5 = 0; d5 < this.shape[5]; d5++) { for (int d6 = 0; d6 < this.shape[6]; d6++) { for (int d7 = 0; d7 < this.shape[7]; d7++) { for (int d8 = 0; d8 < this.shape[8]; d8++) { for (int d9 = 0; d9 < this.shape[9]; d9++) { result[d9][d8][d7][d6][d5][d4][d3][d2][d1][d0] = array[d0][d1][d2][d3][d4][d5][d6][d7][d8][d9]; } } } } } } } } } } return NumpyArrayFactory.from(result); } }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy/wrappers/Dim10Int8NumpyWrapper.java
/* * This file was automatically generated, don't edit it manually. */ package ai.sklearn4j.core.libraries.numpy.wrappers; import ai.sklearn4j.core.libraries.numpy.INumpyArrayWrapper; import ai.sklearn4j.core.libraries.numpy.NumpyArray; import ai.sklearn4j.core.libraries.numpy.NumpyArrayFactory; import ai.sklearn4j.core.libraries.numpy.NumpyOperationException; /** * A wrapper over a 10 dimensions byte array for NumpyArray class. */ public class Dim10Int8NumpyWrapper implements INumpyArrayWrapper { private final byte[][][][][][][][][][] array; private final int[] shape; /** * Instantiate a new wrapper for 10 array. * * @param array The underlying native array object. */ public Dim10Int8NumpyWrapper(byte[][][][][][][][][][] array) { this.array = array; this.shape = new int[]{array.length, array[0].length, array[0][0].length, array[0][0][0].length, array[0][0][0][0].length, array[0][0][0][0][0].length, array[0][0][0][0][0][0].length, array[0][0][0][0][0][0][0].length, array[0][0][0][0][0][0][0][0].length, array[0][0][0][0][0][0][0][0][0].length}; } @Override public int[] getShape() { return shape; } @Override public Object get(int... indices) { return array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]][indices[7]][indices[8]][indices[9]]; } @Override public void set(Object value, int... indices) { this.array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]][indices[7]][indices[8]][indices[9]] = NumpyArrayFactory.toByte(value); } /** * Gets the underlying native array object. * * @return The underlying native array object. */ public byte[][][][][][][][][][] getArray() { return this.array; } @Override public boolean isFloatingPoint() { return false; } @Override public int numberOfBits() { return 8; } @Override public Object getRawArray() { return array; } @Override public NumpyArray wrapInnerSubsetArray(int... indices) { NumpyArray result = null; if (indices.length == 1) { result = NumpyArrayFactory.from(array[indices[0]]); } else if (indices.length == 2) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]]); } else if (indices.length == 3) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]]); } else if (indices.length == 4) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]]); } else if (indices.length == 5) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]]); } else if (indices.length == 6) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]]); } else if (indices.length == 7) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]]); } else if (indices.length == 8) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]][indices[7]]); } else if (indices.length == 9) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]][indices[7]][indices[8]]); } else { throw new NumpyOperationException("Invalid slice for array specified."); } return result; } @Override public NumpyArray transpose() { byte[][][][][][][][][][] result = new byte[shape[9]][shape[8]][shape[7]][shape[6]][shape[5]][shape[4]][shape[3]][shape[2]][shape[1]][shape[0]]; for (int d0 = 0; d0 < this.shape[0]; d0++) { for (int d1 = 0; d1 < this.shape[1]; d1++) { for (int d2 = 0; d2 < this.shape[2]; d2++) { for (int d3 = 0; d3 < this.shape[3]; d3++) { for (int d4 = 0; d4 < this.shape[4]; d4++) { for (int d5 = 0; d5 < this.shape[5]; d5++) { for (int d6 = 0; d6 < this.shape[6]; d6++) { for (int d7 = 0; d7 < this.shape[7]; d7++) { for (int d8 = 0; d8 < this.shape[8]; d8++) { for (int d9 = 0; d9 < this.shape[9]; d9++) { result[d9][d8][d7][d6][d5][d4][d3][d2][d1][d0] = array[d0][d1][d2][d3][d4][d5][d6][d7][d8][d9]; } } } } } } } } } } return NumpyArrayFactory.from(result); } }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy/wrappers/Dim1DoubleNumpyWrapper.java
/* * This file was automatically generated, don't edit it manually. */ package ai.sklearn4j.core.libraries.numpy.wrappers; import ai.sklearn4j.core.libraries.numpy.INumpyArrayWrapper; import ai.sklearn4j.core.libraries.numpy.NumpyArray; import ai.sklearn4j.core.libraries.numpy.NumpyArrayFactory; import ai.sklearn4j.core.libraries.numpy.NumpyOperationException; /** * A wrapper over a 1 dimensions double array for NumpyArray class. */ public class Dim1DoubleNumpyWrapper implements INumpyArrayWrapper { private final double[] array; private final int[] shape; /** * Instantiate a new wrapper for 1 array. * * @param array The underlying native array object. */ public Dim1DoubleNumpyWrapper(double[] array) { this.array = array; this.shape = new int[]{array.length}; } @Override public int[] getShape() { return shape; } @Override public Object get(int... indices) { return array[indices[0]]; } @Override public void set(Object value, int... indices) { this.array[indices[0]] = NumpyArrayFactory.toDouble(value); } /** * Gets the underlying native array object. * * @return The underlying native array object. */ public double[] getArray() { return this.array; } @Override public boolean isFloatingPoint() { return true; } @Override public int numberOfBits() { return 64; } @Override public Object getRawArray() { return array; } @Override public NumpyArray wrapInnerSubsetArray(int... indices) { throw new NumpyOperationException("A single dimension sub array can't be sliced."); } @Override public NumpyArray transpose() { double[] result = new double[shape[0]]; for (int d0 = 0; d0 < this.shape[0]; d0++) { result[d0] = array[d0]; } return NumpyArrayFactory.from(result); } }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy/wrappers/Dim1FloatNumpyWrapper.java
/* * This file was automatically generated, don't edit it manually. */ package ai.sklearn4j.core.libraries.numpy.wrappers; import ai.sklearn4j.core.libraries.numpy.INumpyArrayWrapper; import ai.sklearn4j.core.libraries.numpy.NumpyArray; import ai.sklearn4j.core.libraries.numpy.NumpyArrayFactory; import ai.sklearn4j.core.libraries.numpy.NumpyOperationException; /** * A wrapper over a 1 dimensions float array for NumpyArray class. */ public class Dim1FloatNumpyWrapper implements INumpyArrayWrapper { private final float[] array; private final int[] shape; /** * Instantiate a new wrapper for 1 array. * * @param array The underlying native array object. */ public Dim1FloatNumpyWrapper(float[] array) { this.array = array; this.shape = new int[]{array.length}; } @Override public int[] getShape() { return shape; } @Override public Object get(int... indices) { return array[indices[0]]; } @Override public void set(Object value, int... indices) { this.array[indices[0]] = NumpyArrayFactory.toFloat(value); } /** * Gets the underlying native array object. * * @return The underlying native array object. */ public float[] getArray() { return this.array; } @Override public boolean isFloatingPoint() { return true; } @Override public int numberOfBits() { return 32; } @Override public Object getRawArray() { return array; } @Override public NumpyArray wrapInnerSubsetArray(int... indices) { throw new NumpyOperationException("A single dimension sub array can't be sliced."); } @Override public NumpyArray transpose() { float[] result = new float[shape[0]]; for (int d0 = 0; d0 < this.shape[0]; d0++) { result[d0] = array[d0]; } return NumpyArrayFactory.from(result); } }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy/wrappers/Dim1Int16NumpyWrapper.java
/* * This file was automatically generated, don't edit it manually. */ package ai.sklearn4j.core.libraries.numpy.wrappers; import ai.sklearn4j.core.libraries.numpy.INumpyArrayWrapper; import ai.sklearn4j.core.libraries.numpy.NumpyArray; import ai.sklearn4j.core.libraries.numpy.NumpyArrayFactory; import ai.sklearn4j.core.libraries.numpy.NumpyOperationException; /** * A wrapper over a 1 dimensions short array for NumpyArray class. */ public class Dim1Int16NumpyWrapper implements INumpyArrayWrapper { private final short[] array; private final int[] shape; /** * Instantiate a new wrapper for 1 array. * * @param array The underlying native array object. */ public Dim1Int16NumpyWrapper(short[] array) { this.array = array; this.shape = new int[]{array.length}; } @Override public int[] getShape() { return shape; } @Override public Object get(int... indices) { return array[indices[0]]; } @Override public void set(Object value, int... indices) { this.array[indices[0]] = NumpyArrayFactory.toShort(value); } /** * Gets the underlying native array object. * * @return The underlying native array object. */ public short[] getArray() { return this.array; } @Override public boolean isFloatingPoint() { return false; } @Override public int numberOfBits() { return 16; } @Override public Object getRawArray() { return array; } @Override public NumpyArray wrapInnerSubsetArray(int... indices) { throw new NumpyOperationException("A single dimension sub array can't be sliced."); } @Override public NumpyArray transpose() { short[] result = new short[shape[0]]; for (int d0 = 0; d0 < this.shape[0]; d0++) { result[d0] = array[d0]; } return NumpyArrayFactory.from(result); } }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy/wrappers/Dim1Int32NumpyWrapper.java
/* * This file was automatically generated, don't edit it manually. */ package ai.sklearn4j.core.libraries.numpy.wrappers; import ai.sklearn4j.core.libraries.numpy.INumpyArrayWrapper; import ai.sklearn4j.core.libraries.numpy.NumpyArray; import ai.sklearn4j.core.libraries.numpy.NumpyArrayFactory; import ai.sklearn4j.core.libraries.numpy.NumpyOperationException; /** * A wrapper over a 1 dimensions int array for NumpyArray class. */ public class Dim1Int32NumpyWrapper implements INumpyArrayWrapper { private final int[] array; private final int[] shape; /** * Instantiate a new wrapper for 1 array. * * @param array The underlying native array object. */ public Dim1Int32NumpyWrapper(int[] array) { this.array = array; this.shape = new int[]{array.length}; } @Override public int[] getShape() { return shape; } @Override public Object get(int... indices) { return array[indices[0]]; } @Override public void set(Object value, int... indices) { this.array[indices[0]] = NumpyArrayFactory.toInteger(value); } /** * Gets the underlying native array object. * * @return The underlying native array object. */ public int[] getArray() { return this.array; } @Override public boolean isFloatingPoint() { return false; } @Override public int numberOfBits() { return 32; } @Override public Object getRawArray() { return array; } @Override public NumpyArray wrapInnerSubsetArray(int... indices) { throw new NumpyOperationException("A single dimension sub array can't be sliced."); } @Override public NumpyArray transpose() { int[] result = new int[shape[0]]; for (int d0 = 0; d0 < this.shape[0]; d0++) { result[d0] = array[d0]; } return NumpyArrayFactory.from(result); } }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy/wrappers/Dim1Int64NumpyWrapper.java
/* * This file was automatically generated, don't edit it manually. */ package ai.sklearn4j.core.libraries.numpy.wrappers; import ai.sklearn4j.core.libraries.numpy.INumpyArrayWrapper; import ai.sklearn4j.core.libraries.numpy.NumpyArray; import ai.sklearn4j.core.libraries.numpy.NumpyArrayFactory; import ai.sklearn4j.core.libraries.numpy.NumpyOperationException; /** * A wrapper over a 1 dimensions long array for NumpyArray class. */ public class Dim1Int64NumpyWrapper implements INumpyArrayWrapper { private final long[] array; private final int[] shape; /** * Instantiate a new wrapper for 1 array. * * @param array The underlying native array object. */ public Dim1Int64NumpyWrapper(long[] array) { this.array = array; this.shape = new int[]{array.length}; } @Override public int[] getShape() { return shape; } @Override public Object get(int... indices) { return array[indices[0]]; } @Override public void set(Object value, int... indices) { this.array[indices[0]] = NumpyArrayFactory.toLong(value); } /** * Gets the underlying native array object. * * @return The underlying native array object. */ public long[] getArray() { return this.array; } @Override public boolean isFloatingPoint() { return false; } @Override public int numberOfBits() { return 64; } @Override public Object getRawArray() { return array; } @Override public NumpyArray wrapInnerSubsetArray(int... indices) { throw new NumpyOperationException("A single dimension sub array can't be sliced."); } @Override public NumpyArray transpose() { long[] result = new long[shape[0]]; for (int d0 = 0; d0 < this.shape[0]; d0++) { result[d0] = array[d0]; } return NumpyArrayFactory.from(result); } }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy/wrappers/Dim1Int8NumpyWrapper.java
/* * This file was automatically generated, don't edit it manually. */ package ai.sklearn4j.core.libraries.numpy.wrappers; import ai.sklearn4j.core.libraries.numpy.INumpyArrayWrapper; import ai.sklearn4j.core.libraries.numpy.NumpyArray; import ai.sklearn4j.core.libraries.numpy.NumpyArrayFactory; import ai.sklearn4j.core.libraries.numpy.NumpyOperationException; /** * A wrapper over a 1 dimensions byte array for NumpyArray class. */ public class Dim1Int8NumpyWrapper implements INumpyArrayWrapper { private final byte[] array; private final int[] shape; /** * Instantiate a new wrapper for 1 array. * * @param array The underlying native array object. */ public Dim1Int8NumpyWrapper(byte[] array) { this.array = array; this.shape = new int[]{array.length}; } @Override public int[] getShape() { return shape; } @Override public Object get(int... indices) { return array[indices[0]]; } @Override public void set(Object value, int... indices) { this.array[indices[0]] = NumpyArrayFactory.toByte(value); } /** * Gets the underlying native array object. * * @return The underlying native array object. */ public byte[] getArray() { return this.array; } @Override public boolean isFloatingPoint() { return false; } @Override public int numberOfBits() { return 8; } @Override public Object getRawArray() { return array; } @Override public NumpyArray wrapInnerSubsetArray(int... indices) { throw new NumpyOperationException("A single dimension sub array can't be sliced."); } @Override public NumpyArray transpose() { byte[] result = new byte[shape[0]]; for (int d0 = 0; d0 < this.shape[0]; d0++) { result[d0] = array[d0]; } return NumpyArrayFactory.from(result); } }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy/wrappers/Dim2DoubleNumpyWrapper.java
/* * This file was automatically generated, don't edit it manually. */ package ai.sklearn4j.core.libraries.numpy.wrappers; import ai.sklearn4j.core.libraries.numpy.INumpyArrayWrapper; import ai.sklearn4j.core.libraries.numpy.NumpyArray; import ai.sklearn4j.core.libraries.numpy.NumpyArrayFactory; import ai.sklearn4j.core.libraries.numpy.NumpyOperationException; /** * A wrapper over a 2 dimensions double array for NumpyArray class. */ public class Dim2DoubleNumpyWrapper implements INumpyArrayWrapper { private final double[][] array; private final int[] shape; /** * Instantiate a new wrapper for 2 array. * * @param array The underlying native array object. */ public Dim2DoubleNumpyWrapper(double[][] array) { this.array = array; this.shape = new int[]{array.length, array[0].length}; } @Override public int[] getShape() { return shape; } @Override public Object get(int... indices) { return array[indices[0]][indices[1]]; } @Override public void set(Object value, int... indices) { this.array[indices[0]][indices[1]] = NumpyArrayFactory.toDouble(value); } /** * Gets the underlying native array object. * * @return The underlying native array object. */ public double[][] getArray() { return this.array; } @Override public boolean isFloatingPoint() { return true; } @Override public int numberOfBits() { return 64; } @Override public Object getRawArray() { return array; } @Override public NumpyArray wrapInnerSubsetArray(int... indices) { NumpyArray result = null; if (indices.length == 1) { result = NumpyArrayFactory.from(array[indices[0]]); } else { throw new NumpyOperationException("Invalid slice for array specified."); } return result; } @Override public NumpyArray transpose() { double[][] result = new double[shape[1]][shape[0]]; for (int d0 = 0; d0 < this.shape[0]; d0++) { for (int d1 = 0; d1 < this.shape[1]; d1++) { result[d1][d0] = array[d0][d1]; } } return NumpyArrayFactory.from(result); } }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy/wrappers/Dim2FloatNumpyWrapper.java
/* * This file was automatically generated, don't edit it manually. */ package ai.sklearn4j.core.libraries.numpy.wrappers; import ai.sklearn4j.core.libraries.numpy.INumpyArrayWrapper; import ai.sklearn4j.core.libraries.numpy.NumpyArray; import ai.sklearn4j.core.libraries.numpy.NumpyArrayFactory; import ai.sklearn4j.core.libraries.numpy.NumpyOperationException; /** * A wrapper over a 2 dimensions float array for NumpyArray class. */ public class Dim2FloatNumpyWrapper implements INumpyArrayWrapper { private final float[][] array; private final int[] shape; /** * Instantiate a new wrapper for 2 array. * * @param array The underlying native array object. */ public Dim2FloatNumpyWrapper(float[][] array) { this.array = array; this.shape = new int[]{array.length, array[0].length}; } @Override public int[] getShape() { return shape; } @Override public Object get(int... indices) { return array[indices[0]][indices[1]]; } @Override public void set(Object value, int... indices) { this.array[indices[0]][indices[1]] = NumpyArrayFactory.toFloat(value); } /** * Gets the underlying native array object. * * @return The underlying native array object. */ public float[][] getArray() { return this.array; } @Override public boolean isFloatingPoint() { return true; } @Override public int numberOfBits() { return 32; } @Override public Object getRawArray() { return array; } @Override public NumpyArray wrapInnerSubsetArray(int... indices) { NumpyArray result = null; if (indices.length == 1) { result = NumpyArrayFactory.from(array[indices[0]]); } else { throw new NumpyOperationException("Invalid slice for array specified."); } return result; } @Override public NumpyArray transpose() { float[][] result = new float[shape[1]][shape[0]]; for (int d0 = 0; d0 < this.shape[0]; d0++) { for (int d1 = 0; d1 < this.shape[1]; d1++) { result[d1][d0] = array[d0][d1]; } } return NumpyArrayFactory.from(result); } }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy/wrappers/Dim2Int16NumpyWrapper.java
/* * This file was automatically generated, don't edit it manually. */ package ai.sklearn4j.core.libraries.numpy.wrappers; import ai.sklearn4j.core.libraries.numpy.INumpyArrayWrapper; import ai.sklearn4j.core.libraries.numpy.NumpyArray; import ai.sklearn4j.core.libraries.numpy.NumpyArrayFactory; import ai.sklearn4j.core.libraries.numpy.NumpyOperationException; /** * A wrapper over a 2 dimensions short array for NumpyArray class. */ public class Dim2Int16NumpyWrapper implements INumpyArrayWrapper { private final short[][] array; private final int[] shape; /** * Instantiate a new wrapper for 2 array. * * @param array The underlying native array object. */ public Dim2Int16NumpyWrapper(short[][] array) { this.array = array; this.shape = new int[]{array.length, array[0].length}; } @Override public int[] getShape() { return shape; } @Override public Object get(int... indices) { return array[indices[0]][indices[1]]; } @Override public void set(Object value, int... indices) { this.array[indices[0]][indices[1]] = NumpyArrayFactory.toShort(value); } /** * Gets the underlying native array object. * * @return The underlying native array object. */ public short[][] getArray() { return this.array; } @Override public boolean isFloatingPoint() { return false; } @Override public int numberOfBits() { return 16; } @Override public Object getRawArray() { return array; } @Override public NumpyArray wrapInnerSubsetArray(int... indices) { NumpyArray result = null; if (indices.length == 1) { result = NumpyArrayFactory.from(array[indices[0]]); } else { throw new NumpyOperationException("Invalid slice for array specified."); } return result; } @Override public NumpyArray transpose() { short[][] result = new short[shape[1]][shape[0]]; for (int d0 = 0; d0 < this.shape[0]; d0++) { for (int d1 = 0; d1 < this.shape[1]; d1++) { result[d1][d0] = array[d0][d1]; } } return NumpyArrayFactory.from(result); } }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy/wrappers/Dim2Int32NumpyWrapper.java
/* * This file was automatically generated, don't edit it manually. */ package ai.sklearn4j.core.libraries.numpy.wrappers; import ai.sklearn4j.core.libraries.numpy.INumpyArrayWrapper; import ai.sklearn4j.core.libraries.numpy.NumpyArray; import ai.sklearn4j.core.libraries.numpy.NumpyArrayFactory; import ai.sklearn4j.core.libraries.numpy.NumpyOperationException; /** * A wrapper over a 2 dimensions int array for NumpyArray class. */ public class Dim2Int32NumpyWrapper implements INumpyArrayWrapper { private final int[][] array; private final int[] shape; /** * Instantiate a new wrapper for 2 array. * * @param array The underlying native array object. */ public Dim2Int32NumpyWrapper(int[][] array) { this.array = array; this.shape = new int[]{array.length, array[0].length}; } @Override public int[] getShape() { return shape; } @Override public Object get(int... indices) { return array[indices[0]][indices[1]]; } @Override public void set(Object value, int... indices) { this.array[indices[0]][indices[1]] = NumpyArrayFactory.toInteger(value); } /** * Gets the underlying native array object. * * @return The underlying native array object. */ public int[][] getArray() { return this.array; } @Override public boolean isFloatingPoint() { return false; } @Override public int numberOfBits() { return 32; } @Override public Object getRawArray() { return array; } @Override public NumpyArray wrapInnerSubsetArray(int... indices) { NumpyArray result = null; if (indices.length == 1) { result = NumpyArrayFactory.from(array[indices[0]]); } else { throw new NumpyOperationException("Invalid slice for array specified."); } return result; } @Override public NumpyArray transpose() { int[][] result = new int[shape[1]][shape[0]]; for (int d0 = 0; d0 < this.shape[0]; d0++) { for (int d1 = 0; d1 < this.shape[1]; d1++) { result[d1][d0] = array[d0][d1]; } } return NumpyArrayFactory.from(result); } }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy/wrappers/Dim2Int64NumpyWrapper.java
/* * This file was automatically generated, don't edit it manually. */ package ai.sklearn4j.core.libraries.numpy.wrappers; import ai.sklearn4j.core.libraries.numpy.INumpyArrayWrapper; import ai.sklearn4j.core.libraries.numpy.NumpyArray; import ai.sklearn4j.core.libraries.numpy.NumpyArrayFactory; import ai.sklearn4j.core.libraries.numpy.NumpyOperationException; /** * A wrapper over a 2 dimensions long array for NumpyArray class. */ public class Dim2Int64NumpyWrapper implements INumpyArrayWrapper { private final long[][] array; private final int[] shape; /** * Instantiate a new wrapper for 2 array. * * @param array The underlying native array object. */ public Dim2Int64NumpyWrapper(long[][] array) { this.array = array; this.shape = new int[]{array.length, array[0].length}; } @Override public int[] getShape() { return shape; } @Override public Object get(int... indices) { return array[indices[0]][indices[1]]; } @Override public void set(Object value, int... indices) { this.array[indices[0]][indices[1]] = NumpyArrayFactory.toLong(value); } /** * Gets the underlying native array object. * * @return The underlying native array object. */ public long[][] getArray() { return this.array; } @Override public boolean isFloatingPoint() { return false; } @Override public int numberOfBits() { return 64; } @Override public Object getRawArray() { return array; } @Override public NumpyArray wrapInnerSubsetArray(int... indices) { NumpyArray result = null; if (indices.length == 1) { result = NumpyArrayFactory.from(array[indices[0]]); } else { throw new NumpyOperationException("Invalid slice for array specified."); } return result; } @Override public NumpyArray transpose() { long[][] result = new long[shape[1]][shape[0]]; for (int d0 = 0; d0 < this.shape[0]; d0++) { for (int d1 = 0; d1 < this.shape[1]; d1++) { result[d1][d0] = array[d0][d1]; } } return NumpyArrayFactory.from(result); } }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy/wrappers/Dim2Int8NumpyWrapper.java
/* * This file was automatically generated, don't edit it manually. */ package ai.sklearn4j.core.libraries.numpy.wrappers; import ai.sklearn4j.core.libraries.numpy.INumpyArrayWrapper; import ai.sklearn4j.core.libraries.numpy.NumpyArray; import ai.sklearn4j.core.libraries.numpy.NumpyArrayFactory; import ai.sklearn4j.core.libraries.numpy.NumpyOperationException; /** * A wrapper over a 2 dimensions byte array for NumpyArray class. */ public class Dim2Int8NumpyWrapper implements INumpyArrayWrapper { private final byte[][] array; private final int[] shape; /** * Instantiate a new wrapper for 2 array. * * @param array The underlying native array object. */ public Dim2Int8NumpyWrapper(byte[][] array) { this.array = array; this.shape = new int[]{array.length, array[0].length}; } @Override public int[] getShape() { return shape; } @Override public Object get(int... indices) { return array[indices[0]][indices[1]]; } @Override public void set(Object value, int... indices) { this.array[indices[0]][indices[1]] = NumpyArrayFactory.toByte(value); } /** * Gets the underlying native array object. * * @return The underlying native array object. */ public byte[][] getArray() { return this.array; } @Override public boolean isFloatingPoint() { return false; } @Override public int numberOfBits() { return 8; } @Override public Object getRawArray() { return array; } @Override public NumpyArray wrapInnerSubsetArray(int... indices) { NumpyArray result = null; if (indices.length == 1) { result = NumpyArrayFactory.from(array[indices[0]]); } else { throw new NumpyOperationException("Invalid slice for array specified."); } return result; } @Override public NumpyArray transpose() { byte[][] result = new byte[shape[1]][shape[0]]; for (int d0 = 0; d0 < this.shape[0]; d0++) { for (int d1 = 0; d1 < this.shape[1]; d1++) { result[d1][d0] = array[d0][d1]; } } return NumpyArrayFactory.from(result); } }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy/wrappers/Dim3DoubleNumpyWrapper.java
/* * This file was automatically generated, don't edit it manually. */ package ai.sklearn4j.core.libraries.numpy.wrappers; import ai.sklearn4j.core.libraries.numpy.INumpyArrayWrapper; import ai.sklearn4j.core.libraries.numpy.NumpyArray; import ai.sklearn4j.core.libraries.numpy.NumpyArrayFactory; import ai.sklearn4j.core.libraries.numpy.NumpyOperationException; /** * A wrapper over a 3 dimensions double array for NumpyArray class. */ public class Dim3DoubleNumpyWrapper implements INumpyArrayWrapper { private final double[][][] array; private final int[] shape; /** * Instantiate a new wrapper for 3 array. * * @param array The underlying native array object. */ public Dim3DoubleNumpyWrapper(double[][][] array) { this.array = array; this.shape = new int[]{array.length, array[0].length, array[0][0].length}; } @Override public int[] getShape() { return shape; } @Override public Object get(int... indices) { return array[indices[0]][indices[1]][indices[2]]; } @Override public void set(Object value, int... indices) { this.array[indices[0]][indices[1]][indices[2]] = NumpyArrayFactory.toDouble(value); } /** * Gets the underlying native array object. * * @return The underlying native array object. */ public double[][][] getArray() { return this.array; } @Override public boolean isFloatingPoint() { return true; } @Override public int numberOfBits() { return 64; } @Override public Object getRawArray() { return array; } @Override public NumpyArray wrapInnerSubsetArray(int... indices) { NumpyArray result = null; if (indices.length == 1) { result = NumpyArrayFactory.from(array[indices[0]]); } else if (indices.length == 2) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]]); } else { throw new NumpyOperationException("Invalid slice for array specified."); } return result; } @Override public NumpyArray transpose() { double[][][] result = new double[shape[2]][shape[1]][shape[0]]; for (int d0 = 0; d0 < this.shape[0]; d0++) { for (int d1 = 0; d1 < this.shape[1]; d1++) { for (int d2 = 0; d2 < this.shape[2]; d2++) { result[d2][d1][d0] = array[d0][d1][d2]; } } } return NumpyArrayFactory.from(result); } }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy/wrappers/Dim3FloatNumpyWrapper.java
/* * This file was automatically generated, don't edit it manually. */ package ai.sklearn4j.core.libraries.numpy.wrappers; import ai.sklearn4j.core.libraries.numpy.INumpyArrayWrapper; import ai.sklearn4j.core.libraries.numpy.NumpyArray; import ai.sklearn4j.core.libraries.numpy.NumpyArrayFactory; import ai.sklearn4j.core.libraries.numpy.NumpyOperationException; /** * A wrapper over a 3 dimensions float array for NumpyArray class. */ public class Dim3FloatNumpyWrapper implements INumpyArrayWrapper { private final float[][][] array; private final int[] shape; /** * Instantiate a new wrapper for 3 array. * * @param array The underlying native array object. */ public Dim3FloatNumpyWrapper(float[][][] array) { this.array = array; this.shape = new int[]{array.length, array[0].length, array[0][0].length}; } @Override public int[] getShape() { return shape; } @Override public Object get(int... indices) { return array[indices[0]][indices[1]][indices[2]]; } @Override public void set(Object value, int... indices) { this.array[indices[0]][indices[1]][indices[2]] = NumpyArrayFactory.toFloat(value); } /** * Gets the underlying native array object. * * @return The underlying native array object. */ public float[][][] getArray() { return this.array; } @Override public boolean isFloatingPoint() { return true; } @Override public int numberOfBits() { return 32; } @Override public Object getRawArray() { return array; } @Override public NumpyArray wrapInnerSubsetArray(int... indices) { NumpyArray result = null; if (indices.length == 1) { result = NumpyArrayFactory.from(array[indices[0]]); } else if (indices.length == 2) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]]); } else { throw new NumpyOperationException("Invalid slice for array specified."); } return result; } @Override public NumpyArray transpose() { float[][][] result = new float[shape[2]][shape[1]][shape[0]]; for (int d0 = 0; d0 < this.shape[0]; d0++) { for (int d1 = 0; d1 < this.shape[1]; d1++) { for (int d2 = 0; d2 < this.shape[2]; d2++) { result[d2][d1][d0] = array[d0][d1][d2]; } } } return NumpyArrayFactory.from(result); } }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy/wrappers/Dim3Int16NumpyWrapper.java
/* * This file was automatically generated, don't edit it manually. */ package ai.sklearn4j.core.libraries.numpy.wrappers; import ai.sklearn4j.core.libraries.numpy.INumpyArrayWrapper; import ai.sklearn4j.core.libraries.numpy.NumpyArray; import ai.sklearn4j.core.libraries.numpy.NumpyArrayFactory; import ai.sklearn4j.core.libraries.numpy.NumpyOperationException; /** * A wrapper over a 3 dimensions short array for NumpyArray class. */ public class Dim3Int16NumpyWrapper implements INumpyArrayWrapper { private final short[][][] array; private final int[] shape; /** * Instantiate a new wrapper for 3 array. * * @param array The underlying native array object. */ public Dim3Int16NumpyWrapper(short[][][] array) { this.array = array; this.shape = new int[]{array.length, array[0].length, array[0][0].length}; } @Override public int[] getShape() { return shape; } @Override public Object get(int... indices) { return array[indices[0]][indices[1]][indices[2]]; } @Override public void set(Object value, int... indices) { this.array[indices[0]][indices[1]][indices[2]] = NumpyArrayFactory.toShort(value); } /** * Gets the underlying native array object. * * @return The underlying native array object. */ public short[][][] getArray() { return this.array; } @Override public boolean isFloatingPoint() { return false; } @Override public int numberOfBits() { return 16; } @Override public Object getRawArray() { return array; } @Override public NumpyArray wrapInnerSubsetArray(int... indices) { NumpyArray result = null; if (indices.length == 1) { result = NumpyArrayFactory.from(array[indices[0]]); } else if (indices.length == 2) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]]); } else { throw new NumpyOperationException("Invalid slice for array specified."); } return result; } @Override public NumpyArray transpose() { short[][][] result = new short[shape[2]][shape[1]][shape[0]]; for (int d0 = 0; d0 < this.shape[0]; d0++) { for (int d1 = 0; d1 < this.shape[1]; d1++) { for (int d2 = 0; d2 < this.shape[2]; d2++) { result[d2][d1][d0] = array[d0][d1][d2]; } } } return NumpyArrayFactory.from(result); } }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy/wrappers/Dim3Int32NumpyWrapper.java
/* * This file was automatically generated, don't edit it manually. */ package ai.sklearn4j.core.libraries.numpy.wrappers; import ai.sklearn4j.core.libraries.numpy.INumpyArrayWrapper; import ai.sklearn4j.core.libraries.numpy.NumpyArray; import ai.sklearn4j.core.libraries.numpy.NumpyArrayFactory; import ai.sklearn4j.core.libraries.numpy.NumpyOperationException; /** * A wrapper over a 3 dimensions int array for NumpyArray class. */ public class Dim3Int32NumpyWrapper implements INumpyArrayWrapper { private final int[][][] array; private final int[] shape; /** * Instantiate a new wrapper for 3 array. * * @param array The underlying native array object. */ public Dim3Int32NumpyWrapper(int[][][] array) { this.array = array; this.shape = new int[]{array.length, array[0].length, array[0][0].length}; } @Override public int[] getShape() { return shape; } @Override public Object get(int... indices) { return array[indices[0]][indices[1]][indices[2]]; } @Override public void set(Object value, int... indices) { this.array[indices[0]][indices[1]][indices[2]] = NumpyArrayFactory.toInteger(value); } /** * Gets the underlying native array object. * * @return The underlying native array object. */ public int[][][] getArray() { return this.array; } @Override public boolean isFloatingPoint() { return false; } @Override public int numberOfBits() { return 32; } @Override public Object getRawArray() { return array; } @Override public NumpyArray wrapInnerSubsetArray(int... indices) { NumpyArray result = null; if (indices.length == 1) { result = NumpyArrayFactory.from(array[indices[0]]); } else if (indices.length == 2) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]]); } else { throw new NumpyOperationException("Invalid slice for array specified."); } return result; } @Override public NumpyArray transpose() { int[][][] result = new int[shape[2]][shape[1]][shape[0]]; for (int d0 = 0; d0 < this.shape[0]; d0++) { for (int d1 = 0; d1 < this.shape[1]; d1++) { for (int d2 = 0; d2 < this.shape[2]; d2++) { result[d2][d1][d0] = array[d0][d1][d2]; } } } return NumpyArrayFactory.from(result); } }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy/wrappers/Dim3Int64NumpyWrapper.java
/* * This file was automatically generated, don't edit it manually. */ package ai.sklearn4j.core.libraries.numpy.wrappers; import ai.sklearn4j.core.libraries.numpy.INumpyArrayWrapper; import ai.sklearn4j.core.libraries.numpy.NumpyArray; import ai.sklearn4j.core.libraries.numpy.NumpyArrayFactory; import ai.sklearn4j.core.libraries.numpy.NumpyOperationException; /** * A wrapper over a 3 dimensions long array for NumpyArray class. */ public class Dim3Int64NumpyWrapper implements INumpyArrayWrapper { private final long[][][] array; private final int[] shape; /** * Instantiate a new wrapper for 3 array. * * @param array The underlying native array object. */ public Dim3Int64NumpyWrapper(long[][][] array) { this.array = array; this.shape = new int[]{array.length, array[0].length, array[0][0].length}; } @Override public int[] getShape() { return shape; } @Override public Object get(int... indices) { return array[indices[0]][indices[1]][indices[2]]; } @Override public void set(Object value, int... indices) { this.array[indices[0]][indices[1]][indices[2]] = NumpyArrayFactory.toLong(value); } /** * Gets the underlying native array object. * * @return The underlying native array object. */ public long[][][] getArray() { return this.array; } @Override public boolean isFloatingPoint() { return false; } @Override public int numberOfBits() { return 64; } @Override public Object getRawArray() { return array; } @Override public NumpyArray wrapInnerSubsetArray(int... indices) { NumpyArray result = null; if (indices.length == 1) { result = NumpyArrayFactory.from(array[indices[0]]); } else if (indices.length == 2) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]]); } else { throw new NumpyOperationException("Invalid slice for array specified."); } return result; } @Override public NumpyArray transpose() { long[][][] result = new long[shape[2]][shape[1]][shape[0]]; for (int d0 = 0; d0 < this.shape[0]; d0++) { for (int d1 = 0; d1 < this.shape[1]; d1++) { for (int d2 = 0; d2 < this.shape[2]; d2++) { result[d2][d1][d0] = array[d0][d1][d2]; } } } return NumpyArrayFactory.from(result); } }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy/wrappers/Dim3Int8NumpyWrapper.java
/* * This file was automatically generated, don't edit it manually. */ package ai.sklearn4j.core.libraries.numpy.wrappers; import ai.sklearn4j.core.libraries.numpy.INumpyArrayWrapper; import ai.sklearn4j.core.libraries.numpy.NumpyArray; import ai.sklearn4j.core.libraries.numpy.NumpyArrayFactory; import ai.sklearn4j.core.libraries.numpy.NumpyOperationException; /** * A wrapper over a 3 dimensions byte array for NumpyArray class. */ public class Dim3Int8NumpyWrapper implements INumpyArrayWrapper { private final byte[][][] array; private final int[] shape; /** * Instantiate a new wrapper for 3 array. * * @param array The underlying native array object. */ public Dim3Int8NumpyWrapper(byte[][][] array) { this.array = array; this.shape = new int[]{array.length, array[0].length, array[0][0].length}; } @Override public int[] getShape() { return shape; } @Override public Object get(int... indices) { return array[indices[0]][indices[1]][indices[2]]; } @Override public void set(Object value, int... indices) { this.array[indices[0]][indices[1]][indices[2]] = NumpyArrayFactory.toByte(value); } /** * Gets the underlying native array object. * * @return The underlying native array object. */ public byte[][][] getArray() { return this.array; } @Override public boolean isFloatingPoint() { return false; } @Override public int numberOfBits() { return 8; } @Override public Object getRawArray() { return array; } @Override public NumpyArray wrapInnerSubsetArray(int... indices) { NumpyArray result = null; if (indices.length == 1) { result = NumpyArrayFactory.from(array[indices[0]]); } else if (indices.length == 2) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]]); } else { throw new NumpyOperationException("Invalid slice for array specified."); } return result; } @Override public NumpyArray transpose() { byte[][][] result = new byte[shape[2]][shape[1]][shape[0]]; for (int d0 = 0; d0 < this.shape[0]; d0++) { for (int d1 = 0; d1 < this.shape[1]; d1++) { for (int d2 = 0; d2 < this.shape[2]; d2++) { result[d2][d1][d0] = array[d0][d1][d2]; } } } return NumpyArrayFactory.from(result); } }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy/wrappers/Dim4DoubleNumpyWrapper.java
/* * This file was automatically generated, don't edit it manually. */ package ai.sklearn4j.core.libraries.numpy.wrappers; import ai.sklearn4j.core.libraries.numpy.INumpyArrayWrapper; import ai.sklearn4j.core.libraries.numpy.NumpyArray; import ai.sklearn4j.core.libraries.numpy.NumpyArrayFactory; import ai.sklearn4j.core.libraries.numpy.NumpyOperationException; /** * A wrapper over a 4 dimensions double array for NumpyArray class. */ public class Dim4DoubleNumpyWrapper implements INumpyArrayWrapper { private final double[][][][] array; private final int[] shape; /** * Instantiate a new wrapper for 4 array. * * @param array The underlying native array object. */ public Dim4DoubleNumpyWrapper(double[][][][] array) { this.array = array; this.shape = new int[]{array.length, array[0].length, array[0][0].length, array[0][0][0].length}; } @Override public int[] getShape() { return shape; } @Override public Object get(int... indices) { return array[indices[0]][indices[1]][indices[2]][indices[3]]; } @Override public void set(Object value, int... indices) { this.array[indices[0]][indices[1]][indices[2]][indices[3]] = NumpyArrayFactory.toDouble(value); } /** * Gets the underlying native array object. * * @return The underlying native array object. */ public double[][][][] getArray() { return this.array; } @Override public boolean isFloatingPoint() { return true; } @Override public int numberOfBits() { return 64; } @Override public Object getRawArray() { return array; } @Override public NumpyArray wrapInnerSubsetArray(int... indices) { NumpyArray result = null; if (indices.length == 1) { result = NumpyArrayFactory.from(array[indices[0]]); } else if (indices.length == 2) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]]); } else if (indices.length == 3) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]]); } else { throw new NumpyOperationException("Invalid slice for array specified."); } return result; } @Override public NumpyArray transpose() { double[][][][] result = new double[shape[3]][shape[2]][shape[1]][shape[0]]; for (int d0 = 0; d0 < this.shape[0]; d0++) { for (int d1 = 0; d1 < this.shape[1]; d1++) { for (int d2 = 0; d2 < this.shape[2]; d2++) { for (int d3 = 0; d3 < this.shape[3]; d3++) { result[d3][d2][d1][d0] = array[d0][d1][d2][d3]; } } } } return NumpyArrayFactory.from(result); } }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy/wrappers/Dim4FloatNumpyWrapper.java
/* * This file was automatically generated, don't edit it manually. */ package ai.sklearn4j.core.libraries.numpy.wrappers; import ai.sklearn4j.core.libraries.numpy.INumpyArrayWrapper; import ai.sklearn4j.core.libraries.numpy.NumpyArray; import ai.sklearn4j.core.libraries.numpy.NumpyArrayFactory; import ai.sklearn4j.core.libraries.numpy.NumpyOperationException; /** * A wrapper over a 4 dimensions float array for NumpyArray class. */ public class Dim4FloatNumpyWrapper implements INumpyArrayWrapper { private final float[][][][] array; private final int[] shape; /** * Instantiate a new wrapper for 4 array. * * @param array The underlying native array object. */ public Dim4FloatNumpyWrapper(float[][][][] array) { this.array = array; this.shape = new int[]{array.length, array[0].length, array[0][0].length, array[0][0][0].length}; } @Override public int[] getShape() { return shape; } @Override public Object get(int... indices) { return array[indices[0]][indices[1]][indices[2]][indices[3]]; } @Override public void set(Object value, int... indices) { this.array[indices[0]][indices[1]][indices[2]][indices[3]] = NumpyArrayFactory.toFloat(value); } /** * Gets the underlying native array object. * * @return The underlying native array object. */ public float[][][][] getArray() { return this.array; } @Override public boolean isFloatingPoint() { return true; } @Override public int numberOfBits() { return 32; } @Override public Object getRawArray() { return array; } @Override public NumpyArray wrapInnerSubsetArray(int... indices) { NumpyArray result = null; if (indices.length == 1) { result = NumpyArrayFactory.from(array[indices[0]]); } else if (indices.length == 2) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]]); } else if (indices.length == 3) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]]); } else { throw new NumpyOperationException("Invalid slice for array specified."); } return result; } @Override public NumpyArray transpose() { float[][][][] result = new float[shape[3]][shape[2]][shape[1]][shape[0]]; for (int d0 = 0; d0 < this.shape[0]; d0++) { for (int d1 = 0; d1 < this.shape[1]; d1++) { for (int d2 = 0; d2 < this.shape[2]; d2++) { for (int d3 = 0; d3 < this.shape[3]; d3++) { result[d3][d2][d1][d0] = array[d0][d1][d2][d3]; } } } } return NumpyArrayFactory.from(result); } }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy/wrappers/Dim4Int16NumpyWrapper.java
/* * This file was automatically generated, don't edit it manually. */ package ai.sklearn4j.core.libraries.numpy.wrappers; import ai.sklearn4j.core.libraries.numpy.INumpyArrayWrapper; import ai.sklearn4j.core.libraries.numpy.NumpyArray; import ai.sklearn4j.core.libraries.numpy.NumpyArrayFactory; import ai.sklearn4j.core.libraries.numpy.NumpyOperationException; /** * A wrapper over a 4 dimensions short array for NumpyArray class. */ public class Dim4Int16NumpyWrapper implements INumpyArrayWrapper { private final short[][][][] array; private final int[] shape; /** * Instantiate a new wrapper for 4 array. * * @param array The underlying native array object. */ public Dim4Int16NumpyWrapper(short[][][][] array) { this.array = array; this.shape = new int[]{array.length, array[0].length, array[0][0].length, array[0][0][0].length}; } @Override public int[] getShape() { return shape; } @Override public Object get(int... indices) { return array[indices[0]][indices[1]][indices[2]][indices[3]]; } @Override public void set(Object value, int... indices) { this.array[indices[0]][indices[1]][indices[2]][indices[3]] = NumpyArrayFactory.toShort(value); } /** * Gets the underlying native array object. * * @return The underlying native array object. */ public short[][][][] getArray() { return this.array; } @Override public boolean isFloatingPoint() { return false; } @Override public int numberOfBits() { return 16; } @Override public Object getRawArray() { return array; } @Override public NumpyArray wrapInnerSubsetArray(int... indices) { NumpyArray result = null; if (indices.length == 1) { result = NumpyArrayFactory.from(array[indices[0]]); } else if (indices.length == 2) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]]); } else if (indices.length == 3) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]]); } else { throw new NumpyOperationException("Invalid slice for array specified."); } return result; } @Override public NumpyArray transpose() { short[][][][] result = new short[shape[3]][shape[2]][shape[1]][shape[0]]; for (int d0 = 0; d0 < this.shape[0]; d0++) { for (int d1 = 0; d1 < this.shape[1]; d1++) { for (int d2 = 0; d2 < this.shape[2]; d2++) { for (int d3 = 0; d3 < this.shape[3]; d3++) { result[d3][d2][d1][d0] = array[d0][d1][d2][d3]; } } } } return NumpyArrayFactory.from(result); } }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy/wrappers/Dim4Int32NumpyWrapper.java
/* * This file was automatically generated, don't edit it manually. */ package ai.sklearn4j.core.libraries.numpy.wrappers; import ai.sklearn4j.core.libraries.numpy.INumpyArrayWrapper; import ai.sklearn4j.core.libraries.numpy.NumpyArray; import ai.sklearn4j.core.libraries.numpy.NumpyArrayFactory; import ai.sklearn4j.core.libraries.numpy.NumpyOperationException; /** * A wrapper over a 4 dimensions int array for NumpyArray class. */ public class Dim4Int32NumpyWrapper implements INumpyArrayWrapper { private final int[][][][] array; private final int[] shape; /** * Instantiate a new wrapper for 4 array. * * @param array The underlying native array object. */ public Dim4Int32NumpyWrapper(int[][][][] array) { this.array = array; this.shape = new int[]{array.length, array[0].length, array[0][0].length, array[0][0][0].length}; } @Override public int[] getShape() { return shape; } @Override public Object get(int... indices) { return array[indices[0]][indices[1]][indices[2]][indices[3]]; } @Override public void set(Object value, int... indices) { this.array[indices[0]][indices[1]][indices[2]][indices[3]] = NumpyArrayFactory.toInteger(value); } /** * Gets the underlying native array object. * * @return The underlying native array object. */ public int[][][][] getArray() { return this.array; } @Override public boolean isFloatingPoint() { return false; } @Override public int numberOfBits() { return 32; } @Override public Object getRawArray() { return array; } @Override public NumpyArray wrapInnerSubsetArray(int... indices) { NumpyArray result = null; if (indices.length == 1) { result = NumpyArrayFactory.from(array[indices[0]]); } else if (indices.length == 2) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]]); } else if (indices.length == 3) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]]); } else { throw new NumpyOperationException("Invalid slice for array specified."); } return result; } @Override public NumpyArray transpose() { int[][][][] result = new int[shape[3]][shape[2]][shape[1]][shape[0]]; for (int d0 = 0; d0 < this.shape[0]; d0++) { for (int d1 = 0; d1 < this.shape[1]; d1++) { for (int d2 = 0; d2 < this.shape[2]; d2++) { for (int d3 = 0; d3 < this.shape[3]; d3++) { result[d3][d2][d1][d0] = array[d0][d1][d2][d3]; } } } } return NumpyArrayFactory.from(result); } }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy/wrappers/Dim4Int64NumpyWrapper.java
/* * This file was automatically generated, don't edit it manually. */ package ai.sklearn4j.core.libraries.numpy.wrappers; import ai.sklearn4j.core.libraries.numpy.INumpyArrayWrapper; import ai.sklearn4j.core.libraries.numpy.NumpyArray; import ai.sklearn4j.core.libraries.numpy.NumpyArrayFactory; import ai.sklearn4j.core.libraries.numpy.NumpyOperationException; /** * A wrapper over a 4 dimensions long array for NumpyArray class. */ public class Dim4Int64NumpyWrapper implements INumpyArrayWrapper { private final long[][][][] array; private final int[] shape; /** * Instantiate a new wrapper for 4 array. * * @param array The underlying native array object. */ public Dim4Int64NumpyWrapper(long[][][][] array) { this.array = array; this.shape = new int[]{array.length, array[0].length, array[0][0].length, array[0][0][0].length}; } @Override public int[] getShape() { return shape; } @Override public Object get(int... indices) { return array[indices[0]][indices[1]][indices[2]][indices[3]]; } @Override public void set(Object value, int... indices) { this.array[indices[0]][indices[1]][indices[2]][indices[3]] = NumpyArrayFactory.toLong(value); } /** * Gets the underlying native array object. * * @return The underlying native array object. */ public long[][][][] getArray() { return this.array; } @Override public boolean isFloatingPoint() { return false; } @Override public int numberOfBits() { return 64; } @Override public Object getRawArray() { return array; } @Override public NumpyArray wrapInnerSubsetArray(int... indices) { NumpyArray result = null; if (indices.length == 1) { result = NumpyArrayFactory.from(array[indices[0]]); } else if (indices.length == 2) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]]); } else if (indices.length == 3) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]]); } else { throw new NumpyOperationException("Invalid slice for array specified."); } return result; } @Override public NumpyArray transpose() { long[][][][] result = new long[shape[3]][shape[2]][shape[1]][shape[0]]; for (int d0 = 0; d0 < this.shape[0]; d0++) { for (int d1 = 0; d1 < this.shape[1]; d1++) { for (int d2 = 0; d2 < this.shape[2]; d2++) { for (int d3 = 0; d3 < this.shape[3]; d3++) { result[d3][d2][d1][d0] = array[d0][d1][d2][d3]; } } } } return NumpyArrayFactory.from(result); } }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy/wrappers/Dim4Int8NumpyWrapper.java
/* * This file was automatically generated, don't edit it manually. */ package ai.sklearn4j.core.libraries.numpy.wrappers; import ai.sklearn4j.core.libraries.numpy.INumpyArrayWrapper; import ai.sklearn4j.core.libraries.numpy.NumpyArray; import ai.sklearn4j.core.libraries.numpy.NumpyArrayFactory; import ai.sklearn4j.core.libraries.numpy.NumpyOperationException; /** * A wrapper over a 4 dimensions byte array for NumpyArray class. */ public class Dim4Int8NumpyWrapper implements INumpyArrayWrapper { private final byte[][][][] array; private final int[] shape; /** * Instantiate a new wrapper for 4 array. * * @param array The underlying native array object. */ public Dim4Int8NumpyWrapper(byte[][][][] array) { this.array = array; this.shape = new int[]{array.length, array[0].length, array[0][0].length, array[0][0][0].length}; } @Override public int[] getShape() { return shape; } @Override public Object get(int... indices) { return array[indices[0]][indices[1]][indices[2]][indices[3]]; } @Override public void set(Object value, int... indices) { this.array[indices[0]][indices[1]][indices[2]][indices[3]] = NumpyArrayFactory.toByte(value); } /** * Gets the underlying native array object. * * @return The underlying native array object. */ public byte[][][][] getArray() { return this.array; } @Override public boolean isFloatingPoint() { return false; } @Override public int numberOfBits() { return 8; } @Override public Object getRawArray() { return array; } @Override public NumpyArray wrapInnerSubsetArray(int... indices) { NumpyArray result = null; if (indices.length == 1) { result = NumpyArrayFactory.from(array[indices[0]]); } else if (indices.length == 2) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]]); } else if (indices.length == 3) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]]); } else { throw new NumpyOperationException("Invalid slice for array specified."); } return result; } @Override public NumpyArray transpose() { byte[][][][] result = new byte[shape[3]][shape[2]][shape[1]][shape[0]]; for (int d0 = 0; d0 < this.shape[0]; d0++) { for (int d1 = 0; d1 < this.shape[1]; d1++) { for (int d2 = 0; d2 < this.shape[2]; d2++) { for (int d3 = 0; d3 < this.shape[3]; d3++) { result[d3][d2][d1][d0] = array[d0][d1][d2][d3]; } } } } return NumpyArrayFactory.from(result); } }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy/wrappers/Dim5DoubleNumpyWrapper.java
/* * This file was automatically generated, don't edit it manually. */ package ai.sklearn4j.core.libraries.numpy.wrappers; import ai.sklearn4j.core.libraries.numpy.INumpyArrayWrapper; import ai.sklearn4j.core.libraries.numpy.NumpyArray; import ai.sklearn4j.core.libraries.numpy.NumpyArrayFactory; import ai.sklearn4j.core.libraries.numpy.NumpyOperationException; /** * A wrapper over a 5 dimensions double array for NumpyArray class. */ public class Dim5DoubleNumpyWrapper implements INumpyArrayWrapper { private final double[][][][][] array; private final int[] shape; /** * Instantiate a new wrapper for 5 array. * * @param array The underlying native array object. */ public Dim5DoubleNumpyWrapper(double[][][][][] array) { this.array = array; this.shape = new int[]{array.length, array[0].length, array[0][0].length, array[0][0][0].length, array[0][0][0][0].length}; } @Override public int[] getShape() { return shape; } @Override public Object get(int... indices) { return array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]]; } @Override public void set(Object value, int... indices) { this.array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]] = NumpyArrayFactory.toDouble(value); } /** * Gets the underlying native array object. * * @return The underlying native array object. */ public double[][][][][] getArray() { return this.array; } @Override public boolean isFloatingPoint() { return true; } @Override public int numberOfBits() { return 64; } @Override public Object getRawArray() { return array; } @Override public NumpyArray wrapInnerSubsetArray(int... indices) { NumpyArray result = null; if (indices.length == 1) { result = NumpyArrayFactory.from(array[indices[0]]); } else if (indices.length == 2) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]]); } else if (indices.length == 3) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]]); } else if (indices.length == 4) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]]); } else { throw new NumpyOperationException("Invalid slice for array specified."); } return result; } @Override public NumpyArray transpose() { double[][][][][] result = new double[shape[4]][shape[3]][shape[2]][shape[1]][shape[0]]; for (int d0 = 0; d0 < this.shape[0]; d0++) { for (int d1 = 0; d1 < this.shape[1]; d1++) { for (int d2 = 0; d2 < this.shape[2]; d2++) { for (int d3 = 0; d3 < this.shape[3]; d3++) { for (int d4 = 0; d4 < this.shape[4]; d4++) { result[d4][d3][d2][d1][d0] = array[d0][d1][d2][d3][d4]; } } } } } return NumpyArrayFactory.from(result); } }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy/wrappers/Dim5FloatNumpyWrapper.java
/* * This file was automatically generated, don't edit it manually. */ package ai.sklearn4j.core.libraries.numpy.wrappers; import ai.sklearn4j.core.libraries.numpy.INumpyArrayWrapper; import ai.sklearn4j.core.libraries.numpy.NumpyArray; import ai.sklearn4j.core.libraries.numpy.NumpyArrayFactory; import ai.sklearn4j.core.libraries.numpy.NumpyOperationException; /** * A wrapper over a 5 dimensions float array for NumpyArray class. */ public class Dim5FloatNumpyWrapper implements INumpyArrayWrapper { private final float[][][][][] array; private final int[] shape; /** * Instantiate a new wrapper for 5 array. * * @param array The underlying native array object. */ public Dim5FloatNumpyWrapper(float[][][][][] array) { this.array = array; this.shape = new int[]{array.length, array[0].length, array[0][0].length, array[0][0][0].length, array[0][0][0][0].length}; } @Override public int[] getShape() { return shape; } @Override public Object get(int... indices) { return array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]]; } @Override public void set(Object value, int... indices) { this.array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]] = NumpyArrayFactory.toFloat(value); } /** * Gets the underlying native array object. * * @return The underlying native array object. */ public float[][][][][] getArray() { return this.array; } @Override public boolean isFloatingPoint() { return true; } @Override public int numberOfBits() { return 32; } @Override public Object getRawArray() { return array; } @Override public NumpyArray wrapInnerSubsetArray(int... indices) { NumpyArray result = null; if (indices.length == 1) { result = NumpyArrayFactory.from(array[indices[0]]); } else if (indices.length == 2) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]]); } else if (indices.length == 3) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]]); } else if (indices.length == 4) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]]); } else { throw new NumpyOperationException("Invalid slice for array specified."); } return result; } @Override public NumpyArray transpose() { float[][][][][] result = new float[shape[4]][shape[3]][shape[2]][shape[1]][shape[0]]; for (int d0 = 0; d0 < this.shape[0]; d0++) { for (int d1 = 0; d1 < this.shape[1]; d1++) { for (int d2 = 0; d2 < this.shape[2]; d2++) { for (int d3 = 0; d3 < this.shape[3]; d3++) { for (int d4 = 0; d4 < this.shape[4]; d4++) { result[d4][d3][d2][d1][d0] = array[d0][d1][d2][d3][d4]; } } } } } return NumpyArrayFactory.from(result); } }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy/wrappers/Dim5Int16NumpyWrapper.java
/* * This file was automatically generated, don't edit it manually. */ package ai.sklearn4j.core.libraries.numpy.wrappers; import ai.sklearn4j.core.libraries.numpy.INumpyArrayWrapper; import ai.sklearn4j.core.libraries.numpy.NumpyArray; import ai.sklearn4j.core.libraries.numpy.NumpyArrayFactory; import ai.sklearn4j.core.libraries.numpy.NumpyOperationException; /** * A wrapper over a 5 dimensions short array for NumpyArray class. */ public class Dim5Int16NumpyWrapper implements INumpyArrayWrapper { private final short[][][][][] array; private final int[] shape; /** * Instantiate a new wrapper for 5 array. * * @param array The underlying native array object. */ public Dim5Int16NumpyWrapper(short[][][][][] array) { this.array = array; this.shape = new int[]{array.length, array[0].length, array[0][0].length, array[0][0][0].length, array[0][0][0][0].length}; } @Override public int[] getShape() { return shape; } @Override public Object get(int... indices) { return array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]]; } @Override public void set(Object value, int... indices) { this.array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]] = NumpyArrayFactory.toShort(value); } /** * Gets the underlying native array object. * * @return The underlying native array object. */ public short[][][][][] getArray() { return this.array; } @Override public boolean isFloatingPoint() { return false; } @Override public int numberOfBits() { return 16; } @Override public Object getRawArray() { return array; } @Override public NumpyArray wrapInnerSubsetArray(int... indices) { NumpyArray result = null; if (indices.length == 1) { result = NumpyArrayFactory.from(array[indices[0]]); } else if (indices.length == 2) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]]); } else if (indices.length == 3) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]]); } else if (indices.length == 4) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]]); } else { throw new NumpyOperationException("Invalid slice for array specified."); } return result; } @Override public NumpyArray transpose() { short[][][][][] result = new short[shape[4]][shape[3]][shape[2]][shape[1]][shape[0]]; for (int d0 = 0; d0 < this.shape[0]; d0++) { for (int d1 = 0; d1 < this.shape[1]; d1++) { for (int d2 = 0; d2 < this.shape[2]; d2++) { for (int d3 = 0; d3 < this.shape[3]; d3++) { for (int d4 = 0; d4 < this.shape[4]; d4++) { result[d4][d3][d2][d1][d0] = array[d0][d1][d2][d3][d4]; } } } } } return NumpyArrayFactory.from(result); } }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy/wrappers/Dim5Int32NumpyWrapper.java
/* * This file was automatically generated, don't edit it manually. */ package ai.sklearn4j.core.libraries.numpy.wrappers; import ai.sklearn4j.core.libraries.numpy.INumpyArrayWrapper; import ai.sklearn4j.core.libraries.numpy.NumpyArray; import ai.sklearn4j.core.libraries.numpy.NumpyArrayFactory; import ai.sklearn4j.core.libraries.numpy.NumpyOperationException; /** * A wrapper over a 5 dimensions int array for NumpyArray class. */ public class Dim5Int32NumpyWrapper implements INumpyArrayWrapper { private final int[][][][][] array; private final int[] shape; /** * Instantiate a new wrapper for 5 array. * * @param array The underlying native array object. */ public Dim5Int32NumpyWrapper(int[][][][][] array) { this.array = array; this.shape = new int[]{array.length, array[0].length, array[0][0].length, array[0][0][0].length, array[0][0][0][0].length}; } @Override public int[] getShape() { return shape; } @Override public Object get(int... indices) { return array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]]; } @Override public void set(Object value, int... indices) { this.array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]] = NumpyArrayFactory.toInteger(value); } /** * Gets the underlying native array object. * * @return The underlying native array object. */ public int[][][][][] getArray() { return this.array; } @Override public boolean isFloatingPoint() { return false; } @Override public int numberOfBits() { return 32; } @Override public Object getRawArray() { return array; } @Override public NumpyArray wrapInnerSubsetArray(int... indices) { NumpyArray result = null; if (indices.length == 1) { result = NumpyArrayFactory.from(array[indices[0]]); } else if (indices.length == 2) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]]); } else if (indices.length == 3) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]]); } else if (indices.length == 4) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]]); } else { throw new NumpyOperationException("Invalid slice for array specified."); } return result; } @Override public NumpyArray transpose() { int[][][][][] result = new int[shape[4]][shape[3]][shape[2]][shape[1]][shape[0]]; for (int d0 = 0; d0 < this.shape[0]; d0++) { for (int d1 = 0; d1 < this.shape[1]; d1++) { for (int d2 = 0; d2 < this.shape[2]; d2++) { for (int d3 = 0; d3 < this.shape[3]; d3++) { for (int d4 = 0; d4 < this.shape[4]; d4++) { result[d4][d3][d2][d1][d0] = array[d0][d1][d2][d3][d4]; } } } } } return NumpyArrayFactory.from(result); } }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy/wrappers/Dim5Int64NumpyWrapper.java
/* * This file was automatically generated, don't edit it manually. */ package ai.sklearn4j.core.libraries.numpy.wrappers; import ai.sklearn4j.core.libraries.numpy.INumpyArrayWrapper; import ai.sklearn4j.core.libraries.numpy.NumpyArray; import ai.sklearn4j.core.libraries.numpy.NumpyArrayFactory; import ai.sklearn4j.core.libraries.numpy.NumpyOperationException; /** * A wrapper over a 5 dimensions long array for NumpyArray class. */ public class Dim5Int64NumpyWrapper implements INumpyArrayWrapper { private final long[][][][][] array; private final int[] shape; /** * Instantiate a new wrapper for 5 array. * * @param array The underlying native array object. */ public Dim5Int64NumpyWrapper(long[][][][][] array) { this.array = array; this.shape = new int[]{array.length, array[0].length, array[0][0].length, array[0][0][0].length, array[0][0][0][0].length}; } @Override public int[] getShape() { return shape; } @Override public Object get(int... indices) { return array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]]; } @Override public void set(Object value, int... indices) { this.array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]] = NumpyArrayFactory.toLong(value); } /** * Gets the underlying native array object. * * @return The underlying native array object. */ public long[][][][][] getArray() { return this.array; } @Override public boolean isFloatingPoint() { return false; } @Override public int numberOfBits() { return 64; } @Override public Object getRawArray() { return array; } @Override public NumpyArray wrapInnerSubsetArray(int... indices) { NumpyArray result = null; if (indices.length == 1) { result = NumpyArrayFactory.from(array[indices[0]]); } else if (indices.length == 2) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]]); } else if (indices.length == 3) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]]); } else if (indices.length == 4) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]]); } else { throw new NumpyOperationException("Invalid slice for array specified."); } return result; } @Override public NumpyArray transpose() { long[][][][][] result = new long[shape[4]][shape[3]][shape[2]][shape[1]][shape[0]]; for (int d0 = 0; d0 < this.shape[0]; d0++) { for (int d1 = 0; d1 < this.shape[1]; d1++) { for (int d2 = 0; d2 < this.shape[2]; d2++) { for (int d3 = 0; d3 < this.shape[3]; d3++) { for (int d4 = 0; d4 < this.shape[4]; d4++) { result[d4][d3][d2][d1][d0] = array[d0][d1][d2][d3][d4]; } } } } } return NumpyArrayFactory.from(result); } }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy/wrappers/Dim5Int8NumpyWrapper.java
/* * This file was automatically generated, don't edit it manually. */ package ai.sklearn4j.core.libraries.numpy.wrappers; import ai.sklearn4j.core.libraries.numpy.INumpyArrayWrapper; import ai.sklearn4j.core.libraries.numpy.NumpyArray; import ai.sklearn4j.core.libraries.numpy.NumpyArrayFactory; import ai.sklearn4j.core.libraries.numpy.NumpyOperationException; /** * A wrapper over a 5 dimensions byte array for NumpyArray class. */ public class Dim5Int8NumpyWrapper implements INumpyArrayWrapper { private final byte[][][][][] array; private final int[] shape; /** * Instantiate a new wrapper for 5 array. * * @param array The underlying native array object. */ public Dim5Int8NumpyWrapper(byte[][][][][] array) { this.array = array; this.shape = new int[]{array.length, array[0].length, array[0][0].length, array[0][0][0].length, array[0][0][0][0].length}; } @Override public int[] getShape() { return shape; } @Override public Object get(int... indices) { return array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]]; } @Override public void set(Object value, int... indices) { this.array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]] = NumpyArrayFactory.toByte(value); } /** * Gets the underlying native array object. * * @return The underlying native array object. */ public byte[][][][][] getArray() { return this.array; } @Override public boolean isFloatingPoint() { return false; } @Override public int numberOfBits() { return 8; } @Override public Object getRawArray() { return array; } @Override public NumpyArray wrapInnerSubsetArray(int... indices) { NumpyArray result = null; if (indices.length == 1) { result = NumpyArrayFactory.from(array[indices[0]]); } else if (indices.length == 2) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]]); } else if (indices.length == 3) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]]); } else if (indices.length == 4) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]]); } else { throw new NumpyOperationException("Invalid slice for array specified."); } return result; } @Override public NumpyArray transpose() { byte[][][][][] result = new byte[shape[4]][shape[3]][shape[2]][shape[1]][shape[0]]; for (int d0 = 0; d0 < this.shape[0]; d0++) { for (int d1 = 0; d1 < this.shape[1]; d1++) { for (int d2 = 0; d2 < this.shape[2]; d2++) { for (int d3 = 0; d3 < this.shape[3]; d3++) { for (int d4 = 0; d4 < this.shape[4]; d4++) { result[d4][d3][d2][d1][d0] = array[d0][d1][d2][d3][d4]; } } } } } return NumpyArrayFactory.from(result); } }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy/wrappers/Dim6DoubleNumpyWrapper.java
/* * This file was automatically generated, don't edit it manually. */ package ai.sklearn4j.core.libraries.numpy.wrappers; import ai.sklearn4j.core.libraries.numpy.INumpyArrayWrapper; import ai.sklearn4j.core.libraries.numpy.NumpyArray; import ai.sklearn4j.core.libraries.numpy.NumpyArrayFactory; import ai.sklearn4j.core.libraries.numpy.NumpyOperationException; /** * A wrapper over a 6 dimensions double array for NumpyArray class. */ public class Dim6DoubleNumpyWrapper implements INumpyArrayWrapper { private final double[][][][][][] array; private final int[] shape; /** * Instantiate a new wrapper for 6 array. * * @param array The underlying native array object. */ public Dim6DoubleNumpyWrapper(double[][][][][][] array) { this.array = array; this.shape = new int[]{array.length, array[0].length, array[0][0].length, array[0][0][0].length, array[0][0][0][0].length, array[0][0][0][0][0].length}; } @Override public int[] getShape() { return shape; } @Override public Object get(int... indices) { return array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]]; } @Override public void set(Object value, int... indices) { this.array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]] = NumpyArrayFactory.toDouble(value); } /** * Gets the underlying native array object. * * @return The underlying native array object. */ public double[][][][][][] getArray() { return this.array; } @Override public boolean isFloatingPoint() { return true; } @Override public int numberOfBits() { return 64; } @Override public Object getRawArray() { return array; } @Override public NumpyArray wrapInnerSubsetArray(int... indices) { NumpyArray result = null; if (indices.length == 1) { result = NumpyArrayFactory.from(array[indices[0]]); } else if (indices.length == 2) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]]); } else if (indices.length == 3) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]]); } else if (indices.length == 4) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]]); } else if (indices.length == 5) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]]); } else { throw new NumpyOperationException("Invalid slice for array specified."); } return result; } @Override public NumpyArray transpose() { double[][][][][][] result = new double[shape[5]][shape[4]][shape[3]][shape[2]][shape[1]][shape[0]]; for (int d0 = 0; d0 < this.shape[0]; d0++) { for (int d1 = 0; d1 < this.shape[1]; d1++) { for (int d2 = 0; d2 < this.shape[2]; d2++) { for (int d3 = 0; d3 < this.shape[3]; d3++) { for (int d4 = 0; d4 < this.shape[4]; d4++) { for (int d5 = 0; d5 < this.shape[5]; d5++) { result[d5][d4][d3][d2][d1][d0] = array[d0][d1][d2][d3][d4][d5]; } } } } } } return NumpyArrayFactory.from(result); } }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy/wrappers/Dim6FloatNumpyWrapper.java
/* * This file was automatically generated, don't edit it manually. */ package ai.sklearn4j.core.libraries.numpy.wrappers; import ai.sklearn4j.core.libraries.numpy.INumpyArrayWrapper; import ai.sklearn4j.core.libraries.numpy.NumpyArray; import ai.sklearn4j.core.libraries.numpy.NumpyArrayFactory; import ai.sklearn4j.core.libraries.numpy.NumpyOperationException; /** * A wrapper over a 6 dimensions float array for NumpyArray class. */ public class Dim6FloatNumpyWrapper implements INumpyArrayWrapper { private final float[][][][][][] array; private final int[] shape; /** * Instantiate a new wrapper for 6 array. * * @param array The underlying native array object. */ public Dim6FloatNumpyWrapper(float[][][][][][] array) { this.array = array; this.shape = new int[]{array.length, array[0].length, array[0][0].length, array[0][0][0].length, array[0][0][0][0].length, array[0][0][0][0][0].length}; } @Override public int[] getShape() { return shape; } @Override public Object get(int... indices) { return array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]]; } @Override public void set(Object value, int... indices) { this.array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]] = NumpyArrayFactory.toFloat(value); } /** * Gets the underlying native array object. * * @return The underlying native array object. */ public float[][][][][][] getArray() { return this.array; } @Override public boolean isFloatingPoint() { return true; } @Override public int numberOfBits() { return 32; } @Override public Object getRawArray() { return array; } @Override public NumpyArray wrapInnerSubsetArray(int... indices) { NumpyArray result = null; if (indices.length == 1) { result = NumpyArrayFactory.from(array[indices[0]]); } else if (indices.length == 2) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]]); } else if (indices.length == 3) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]]); } else if (indices.length == 4) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]]); } else if (indices.length == 5) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]]); } else { throw new NumpyOperationException("Invalid slice for array specified."); } return result; } @Override public NumpyArray transpose() { float[][][][][][] result = new float[shape[5]][shape[4]][shape[3]][shape[2]][shape[1]][shape[0]]; for (int d0 = 0; d0 < this.shape[0]; d0++) { for (int d1 = 0; d1 < this.shape[1]; d1++) { for (int d2 = 0; d2 < this.shape[2]; d2++) { for (int d3 = 0; d3 < this.shape[3]; d3++) { for (int d4 = 0; d4 < this.shape[4]; d4++) { for (int d5 = 0; d5 < this.shape[5]; d5++) { result[d5][d4][d3][d2][d1][d0] = array[d0][d1][d2][d3][d4][d5]; } } } } } } return NumpyArrayFactory.from(result); } }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy/wrappers/Dim6Int16NumpyWrapper.java
/* * This file was automatically generated, don't edit it manually. */ package ai.sklearn4j.core.libraries.numpy.wrappers; import ai.sklearn4j.core.libraries.numpy.INumpyArrayWrapper; import ai.sklearn4j.core.libraries.numpy.NumpyArray; import ai.sklearn4j.core.libraries.numpy.NumpyArrayFactory; import ai.sklearn4j.core.libraries.numpy.NumpyOperationException; /** * A wrapper over a 6 dimensions short array for NumpyArray class. */ public class Dim6Int16NumpyWrapper implements INumpyArrayWrapper { private final short[][][][][][] array; private final int[] shape; /** * Instantiate a new wrapper for 6 array. * * @param array The underlying native array object. */ public Dim6Int16NumpyWrapper(short[][][][][][] array) { this.array = array; this.shape = new int[]{array.length, array[0].length, array[0][0].length, array[0][0][0].length, array[0][0][0][0].length, array[0][0][0][0][0].length}; } @Override public int[] getShape() { return shape; } @Override public Object get(int... indices) { return array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]]; } @Override public void set(Object value, int... indices) { this.array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]] = NumpyArrayFactory.toShort(value); } /** * Gets the underlying native array object. * * @return The underlying native array object. */ public short[][][][][][] getArray() { return this.array; } @Override public boolean isFloatingPoint() { return false; } @Override public int numberOfBits() { return 16; } @Override public Object getRawArray() { return array; } @Override public NumpyArray wrapInnerSubsetArray(int... indices) { NumpyArray result = null; if (indices.length == 1) { result = NumpyArrayFactory.from(array[indices[0]]); } else if (indices.length == 2) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]]); } else if (indices.length == 3) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]]); } else if (indices.length == 4) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]]); } else if (indices.length == 5) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]]); } else { throw new NumpyOperationException("Invalid slice for array specified."); } return result; } @Override public NumpyArray transpose() { short[][][][][][] result = new short[shape[5]][shape[4]][shape[3]][shape[2]][shape[1]][shape[0]]; for (int d0 = 0; d0 < this.shape[0]; d0++) { for (int d1 = 0; d1 < this.shape[1]; d1++) { for (int d2 = 0; d2 < this.shape[2]; d2++) { for (int d3 = 0; d3 < this.shape[3]; d3++) { for (int d4 = 0; d4 < this.shape[4]; d4++) { for (int d5 = 0; d5 < this.shape[5]; d5++) { result[d5][d4][d3][d2][d1][d0] = array[d0][d1][d2][d3][d4][d5]; } } } } } } return NumpyArrayFactory.from(result); } }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy/wrappers/Dim6Int32NumpyWrapper.java
/* * This file was automatically generated, don't edit it manually. */ package ai.sklearn4j.core.libraries.numpy.wrappers; import ai.sklearn4j.core.libraries.numpy.INumpyArrayWrapper; import ai.sklearn4j.core.libraries.numpy.NumpyArray; import ai.sklearn4j.core.libraries.numpy.NumpyArrayFactory; import ai.sklearn4j.core.libraries.numpy.NumpyOperationException; /** * A wrapper over a 6 dimensions int array for NumpyArray class. */ public class Dim6Int32NumpyWrapper implements INumpyArrayWrapper { private final int[][][][][][] array; private final int[] shape; /** * Instantiate a new wrapper for 6 array. * * @param array The underlying native array object. */ public Dim6Int32NumpyWrapper(int[][][][][][] array) { this.array = array; this.shape = new int[]{array.length, array[0].length, array[0][0].length, array[0][0][0].length, array[0][0][0][0].length, array[0][0][0][0][0].length}; } @Override public int[] getShape() { return shape; } @Override public Object get(int... indices) { return array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]]; } @Override public void set(Object value, int... indices) { this.array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]] = NumpyArrayFactory.toInteger(value); } /** * Gets the underlying native array object. * * @return The underlying native array object. */ public int[][][][][][] getArray() { return this.array; } @Override public boolean isFloatingPoint() { return false; } @Override public int numberOfBits() { return 32; } @Override public Object getRawArray() { return array; } @Override public NumpyArray wrapInnerSubsetArray(int... indices) { NumpyArray result = null; if (indices.length == 1) { result = NumpyArrayFactory.from(array[indices[0]]); } else if (indices.length == 2) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]]); } else if (indices.length == 3) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]]); } else if (indices.length == 4) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]]); } else if (indices.length == 5) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]]); } else { throw new NumpyOperationException("Invalid slice for array specified."); } return result; } @Override public NumpyArray transpose() { int[][][][][][] result = new int[shape[5]][shape[4]][shape[3]][shape[2]][shape[1]][shape[0]]; for (int d0 = 0; d0 < this.shape[0]; d0++) { for (int d1 = 0; d1 < this.shape[1]; d1++) { for (int d2 = 0; d2 < this.shape[2]; d2++) { for (int d3 = 0; d3 < this.shape[3]; d3++) { for (int d4 = 0; d4 < this.shape[4]; d4++) { for (int d5 = 0; d5 < this.shape[5]; d5++) { result[d5][d4][d3][d2][d1][d0] = array[d0][d1][d2][d3][d4][d5]; } } } } } } return NumpyArrayFactory.from(result); } }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy/wrappers/Dim6Int64NumpyWrapper.java
/* * This file was automatically generated, don't edit it manually. */ package ai.sklearn4j.core.libraries.numpy.wrappers; import ai.sklearn4j.core.libraries.numpy.INumpyArrayWrapper; import ai.sklearn4j.core.libraries.numpy.NumpyArray; import ai.sklearn4j.core.libraries.numpy.NumpyArrayFactory; import ai.sklearn4j.core.libraries.numpy.NumpyOperationException; /** * A wrapper over a 6 dimensions long array for NumpyArray class. */ public class Dim6Int64NumpyWrapper implements INumpyArrayWrapper { private final long[][][][][][] array; private final int[] shape; /** * Instantiate a new wrapper for 6 array. * * @param array The underlying native array object. */ public Dim6Int64NumpyWrapper(long[][][][][][] array) { this.array = array; this.shape = new int[]{array.length, array[0].length, array[0][0].length, array[0][0][0].length, array[0][0][0][0].length, array[0][0][0][0][0].length}; } @Override public int[] getShape() { return shape; } @Override public Object get(int... indices) { return array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]]; } @Override public void set(Object value, int... indices) { this.array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]] = NumpyArrayFactory.toLong(value); } /** * Gets the underlying native array object. * * @return The underlying native array object. */ public long[][][][][][] getArray() { return this.array; } @Override public boolean isFloatingPoint() { return false; } @Override public int numberOfBits() { return 64; } @Override public Object getRawArray() { return array; } @Override public NumpyArray wrapInnerSubsetArray(int... indices) { NumpyArray result = null; if (indices.length == 1) { result = NumpyArrayFactory.from(array[indices[0]]); } else if (indices.length == 2) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]]); } else if (indices.length == 3) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]]); } else if (indices.length == 4) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]]); } else if (indices.length == 5) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]]); } else { throw new NumpyOperationException("Invalid slice for array specified."); } return result; } @Override public NumpyArray transpose() { long[][][][][][] result = new long[shape[5]][shape[4]][shape[3]][shape[2]][shape[1]][shape[0]]; for (int d0 = 0; d0 < this.shape[0]; d0++) { for (int d1 = 0; d1 < this.shape[1]; d1++) { for (int d2 = 0; d2 < this.shape[2]; d2++) { for (int d3 = 0; d3 < this.shape[3]; d3++) { for (int d4 = 0; d4 < this.shape[4]; d4++) { for (int d5 = 0; d5 < this.shape[5]; d5++) { result[d5][d4][d3][d2][d1][d0] = array[d0][d1][d2][d3][d4][d5]; } } } } } } return NumpyArrayFactory.from(result); } }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy/wrappers/Dim6Int8NumpyWrapper.java
/* * This file was automatically generated, don't edit it manually. */ package ai.sklearn4j.core.libraries.numpy.wrappers; import ai.sklearn4j.core.libraries.numpy.INumpyArrayWrapper; import ai.sklearn4j.core.libraries.numpy.NumpyArray; import ai.sklearn4j.core.libraries.numpy.NumpyArrayFactory; import ai.sklearn4j.core.libraries.numpy.NumpyOperationException; /** * A wrapper over a 6 dimensions byte array for NumpyArray class. */ public class Dim6Int8NumpyWrapper implements INumpyArrayWrapper { private final byte[][][][][][] array; private final int[] shape; /** * Instantiate a new wrapper for 6 array. * * @param array The underlying native array object. */ public Dim6Int8NumpyWrapper(byte[][][][][][] array) { this.array = array; this.shape = new int[]{array.length, array[0].length, array[0][0].length, array[0][0][0].length, array[0][0][0][0].length, array[0][0][0][0][0].length}; } @Override public int[] getShape() { return shape; } @Override public Object get(int... indices) { return array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]]; } @Override public void set(Object value, int... indices) { this.array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]] = NumpyArrayFactory.toByte(value); } /** * Gets the underlying native array object. * * @return The underlying native array object. */ public byte[][][][][][] getArray() { return this.array; } @Override public boolean isFloatingPoint() { return false; } @Override public int numberOfBits() { return 8; } @Override public Object getRawArray() { return array; } @Override public NumpyArray wrapInnerSubsetArray(int... indices) { NumpyArray result = null; if (indices.length == 1) { result = NumpyArrayFactory.from(array[indices[0]]); } else if (indices.length == 2) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]]); } else if (indices.length == 3) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]]); } else if (indices.length == 4) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]]); } else if (indices.length == 5) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]]); } else { throw new NumpyOperationException("Invalid slice for array specified."); } return result; } @Override public NumpyArray transpose() { byte[][][][][][] result = new byte[shape[5]][shape[4]][shape[3]][shape[2]][shape[1]][shape[0]]; for (int d0 = 0; d0 < this.shape[0]; d0++) { for (int d1 = 0; d1 < this.shape[1]; d1++) { for (int d2 = 0; d2 < this.shape[2]; d2++) { for (int d3 = 0; d3 < this.shape[3]; d3++) { for (int d4 = 0; d4 < this.shape[4]; d4++) { for (int d5 = 0; d5 < this.shape[5]; d5++) { result[d5][d4][d3][d2][d1][d0] = array[d0][d1][d2][d3][d4][d5]; } } } } } } return NumpyArrayFactory.from(result); } }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy/wrappers/Dim7DoubleNumpyWrapper.java
/* * This file was automatically generated, don't edit it manually. */ package ai.sklearn4j.core.libraries.numpy.wrappers; import ai.sklearn4j.core.libraries.numpy.INumpyArrayWrapper; import ai.sklearn4j.core.libraries.numpy.NumpyArray; import ai.sklearn4j.core.libraries.numpy.NumpyArrayFactory; import ai.sklearn4j.core.libraries.numpy.NumpyOperationException; /** * A wrapper over a 7 dimensions double array for NumpyArray class. */ public class Dim7DoubleNumpyWrapper implements INumpyArrayWrapper { private final double[][][][][][][] array; private final int[] shape; /** * Instantiate a new wrapper for 7 array. * * @param array The underlying native array object. */ public Dim7DoubleNumpyWrapper(double[][][][][][][] array) { this.array = array; this.shape = new int[]{array.length, array[0].length, array[0][0].length, array[0][0][0].length, array[0][0][0][0].length, array[0][0][0][0][0].length, array[0][0][0][0][0][0].length}; } @Override public int[] getShape() { return shape; } @Override public Object get(int... indices) { return array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]]; } @Override public void set(Object value, int... indices) { this.array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]] = NumpyArrayFactory.toDouble(value); } /** * Gets the underlying native array object. * * @return The underlying native array object. */ public double[][][][][][][] getArray() { return this.array; } @Override public boolean isFloatingPoint() { return true; } @Override public int numberOfBits() { return 64; } @Override public Object getRawArray() { return array; } @Override public NumpyArray wrapInnerSubsetArray(int... indices) { NumpyArray result = null; if (indices.length == 1) { result = NumpyArrayFactory.from(array[indices[0]]); } else if (indices.length == 2) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]]); } else if (indices.length == 3) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]]); } else if (indices.length == 4) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]]); } else if (indices.length == 5) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]]); } else if (indices.length == 6) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]]); } else { throw new NumpyOperationException("Invalid slice for array specified."); } return result; } @Override public NumpyArray transpose() { double[][][][][][][] result = new double[shape[6]][shape[5]][shape[4]][shape[3]][shape[2]][shape[1]][shape[0]]; for (int d0 = 0; d0 < this.shape[0]; d0++) { for (int d1 = 0; d1 < this.shape[1]; d1++) { for (int d2 = 0; d2 < this.shape[2]; d2++) { for (int d3 = 0; d3 < this.shape[3]; d3++) { for (int d4 = 0; d4 < this.shape[4]; d4++) { for (int d5 = 0; d5 < this.shape[5]; d5++) { for (int d6 = 0; d6 < this.shape[6]; d6++) { result[d6][d5][d4][d3][d2][d1][d0] = array[d0][d1][d2][d3][d4][d5][d6]; } } } } } } } return NumpyArrayFactory.from(result); } }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy/wrappers/Dim7FloatNumpyWrapper.java
/* * This file was automatically generated, don't edit it manually. */ package ai.sklearn4j.core.libraries.numpy.wrappers; import ai.sklearn4j.core.libraries.numpy.INumpyArrayWrapper; import ai.sklearn4j.core.libraries.numpy.NumpyArray; import ai.sklearn4j.core.libraries.numpy.NumpyArrayFactory; import ai.sklearn4j.core.libraries.numpy.NumpyOperationException; /** * A wrapper over a 7 dimensions float array for NumpyArray class. */ public class Dim7FloatNumpyWrapper implements INumpyArrayWrapper { private final float[][][][][][][] array; private final int[] shape; /** * Instantiate a new wrapper for 7 array. * * @param array The underlying native array object. */ public Dim7FloatNumpyWrapper(float[][][][][][][] array) { this.array = array; this.shape = new int[]{array.length, array[0].length, array[0][0].length, array[0][0][0].length, array[0][0][0][0].length, array[0][0][0][0][0].length, array[0][0][0][0][0][0].length}; } @Override public int[] getShape() { return shape; } @Override public Object get(int... indices) { return array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]]; } @Override public void set(Object value, int... indices) { this.array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]] = NumpyArrayFactory.toFloat(value); } /** * Gets the underlying native array object. * * @return The underlying native array object. */ public float[][][][][][][] getArray() { return this.array; } @Override public boolean isFloatingPoint() { return true; } @Override public int numberOfBits() { return 32; } @Override public Object getRawArray() { return array; } @Override public NumpyArray wrapInnerSubsetArray(int... indices) { NumpyArray result = null; if (indices.length == 1) { result = NumpyArrayFactory.from(array[indices[0]]); } else if (indices.length == 2) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]]); } else if (indices.length == 3) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]]); } else if (indices.length == 4) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]]); } else if (indices.length == 5) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]]); } else if (indices.length == 6) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]]); } else { throw new NumpyOperationException("Invalid slice for array specified."); } return result; } @Override public NumpyArray transpose() { float[][][][][][][] result = new float[shape[6]][shape[5]][shape[4]][shape[3]][shape[2]][shape[1]][shape[0]]; for (int d0 = 0; d0 < this.shape[0]; d0++) { for (int d1 = 0; d1 < this.shape[1]; d1++) { for (int d2 = 0; d2 < this.shape[2]; d2++) { for (int d3 = 0; d3 < this.shape[3]; d3++) { for (int d4 = 0; d4 < this.shape[4]; d4++) { for (int d5 = 0; d5 < this.shape[5]; d5++) { for (int d6 = 0; d6 < this.shape[6]; d6++) { result[d6][d5][d4][d3][d2][d1][d0] = array[d0][d1][d2][d3][d4][d5][d6]; } } } } } } } return NumpyArrayFactory.from(result); } }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy/wrappers/Dim7Int16NumpyWrapper.java
/* * This file was automatically generated, don't edit it manually. */ package ai.sklearn4j.core.libraries.numpy.wrappers; import ai.sklearn4j.core.libraries.numpy.INumpyArrayWrapper; import ai.sklearn4j.core.libraries.numpy.NumpyArray; import ai.sklearn4j.core.libraries.numpy.NumpyArrayFactory; import ai.sklearn4j.core.libraries.numpy.NumpyOperationException; /** * A wrapper over a 7 dimensions short array for NumpyArray class. */ public class Dim7Int16NumpyWrapper implements INumpyArrayWrapper { private final short[][][][][][][] array; private final int[] shape; /** * Instantiate a new wrapper for 7 array. * * @param array The underlying native array object. */ public Dim7Int16NumpyWrapper(short[][][][][][][] array) { this.array = array; this.shape = new int[]{array.length, array[0].length, array[0][0].length, array[0][0][0].length, array[0][0][0][0].length, array[0][0][0][0][0].length, array[0][0][0][0][0][0].length}; } @Override public int[] getShape() { return shape; } @Override public Object get(int... indices) { return array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]]; } @Override public void set(Object value, int... indices) { this.array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]] = NumpyArrayFactory.toShort(value); } /** * Gets the underlying native array object. * * @return The underlying native array object. */ public short[][][][][][][] getArray() { return this.array; } @Override public boolean isFloatingPoint() { return false; } @Override public int numberOfBits() { return 16; } @Override public Object getRawArray() { return array; } @Override public NumpyArray wrapInnerSubsetArray(int... indices) { NumpyArray result = null; if (indices.length == 1) { result = NumpyArrayFactory.from(array[indices[0]]); } else if (indices.length == 2) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]]); } else if (indices.length == 3) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]]); } else if (indices.length == 4) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]]); } else if (indices.length == 5) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]]); } else if (indices.length == 6) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]]); } else { throw new NumpyOperationException("Invalid slice for array specified."); } return result; } @Override public NumpyArray transpose() { short[][][][][][][] result = new short[shape[6]][shape[5]][shape[4]][shape[3]][shape[2]][shape[1]][shape[0]]; for (int d0 = 0; d0 < this.shape[0]; d0++) { for (int d1 = 0; d1 < this.shape[1]; d1++) { for (int d2 = 0; d2 < this.shape[2]; d2++) { for (int d3 = 0; d3 < this.shape[3]; d3++) { for (int d4 = 0; d4 < this.shape[4]; d4++) { for (int d5 = 0; d5 < this.shape[5]; d5++) { for (int d6 = 0; d6 < this.shape[6]; d6++) { result[d6][d5][d4][d3][d2][d1][d0] = array[d0][d1][d2][d3][d4][d5][d6]; } } } } } } } return NumpyArrayFactory.from(result); } }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy/wrappers/Dim7Int32NumpyWrapper.java
/* * This file was automatically generated, don't edit it manually. */ package ai.sklearn4j.core.libraries.numpy.wrappers; import ai.sklearn4j.core.libraries.numpy.INumpyArrayWrapper; import ai.sklearn4j.core.libraries.numpy.NumpyArray; import ai.sklearn4j.core.libraries.numpy.NumpyArrayFactory; import ai.sklearn4j.core.libraries.numpy.NumpyOperationException; /** * A wrapper over a 7 dimensions int array for NumpyArray class. */ public class Dim7Int32NumpyWrapper implements INumpyArrayWrapper { private final int[][][][][][][] array; private final int[] shape; /** * Instantiate a new wrapper for 7 array. * * @param array The underlying native array object. */ public Dim7Int32NumpyWrapper(int[][][][][][][] array) { this.array = array; this.shape = new int[]{array.length, array[0].length, array[0][0].length, array[0][0][0].length, array[0][0][0][0].length, array[0][0][0][0][0].length, array[0][0][0][0][0][0].length}; } @Override public int[] getShape() { return shape; } @Override public Object get(int... indices) { return array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]]; } @Override public void set(Object value, int... indices) { this.array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]] = NumpyArrayFactory.toInteger(value); } /** * Gets the underlying native array object. * * @return The underlying native array object. */ public int[][][][][][][] getArray() { return this.array; } @Override public boolean isFloatingPoint() { return false; } @Override public int numberOfBits() { return 32; } @Override public Object getRawArray() { return array; } @Override public NumpyArray wrapInnerSubsetArray(int... indices) { NumpyArray result = null; if (indices.length == 1) { result = NumpyArrayFactory.from(array[indices[0]]); } else if (indices.length == 2) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]]); } else if (indices.length == 3) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]]); } else if (indices.length == 4) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]]); } else if (indices.length == 5) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]]); } else if (indices.length == 6) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]]); } else { throw new NumpyOperationException("Invalid slice for array specified."); } return result; } @Override public NumpyArray transpose() { int[][][][][][][] result = new int[shape[6]][shape[5]][shape[4]][shape[3]][shape[2]][shape[1]][shape[0]]; for (int d0 = 0; d0 < this.shape[0]; d0++) { for (int d1 = 0; d1 < this.shape[1]; d1++) { for (int d2 = 0; d2 < this.shape[2]; d2++) { for (int d3 = 0; d3 < this.shape[3]; d3++) { for (int d4 = 0; d4 < this.shape[4]; d4++) { for (int d5 = 0; d5 < this.shape[5]; d5++) { for (int d6 = 0; d6 < this.shape[6]; d6++) { result[d6][d5][d4][d3][d2][d1][d0] = array[d0][d1][d2][d3][d4][d5][d6]; } } } } } } } return NumpyArrayFactory.from(result); } }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy/wrappers/Dim7Int64NumpyWrapper.java
/* * This file was automatically generated, don't edit it manually. */ package ai.sklearn4j.core.libraries.numpy.wrappers; import ai.sklearn4j.core.libraries.numpy.INumpyArrayWrapper; import ai.sklearn4j.core.libraries.numpy.NumpyArray; import ai.sklearn4j.core.libraries.numpy.NumpyArrayFactory; import ai.sklearn4j.core.libraries.numpy.NumpyOperationException; /** * A wrapper over a 7 dimensions long array for NumpyArray class. */ public class Dim7Int64NumpyWrapper implements INumpyArrayWrapper { private final long[][][][][][][] array; private final int[] shape; /** * Instantiate a new wrapper for 7 array. * * @param array The underlying native array object. */ public Dim7Int64NumpyWrapper(long[][][][][][][] array) { this.array = array; this.shape = new int[]{array.length, array[0].length, array[0][0].length, array[0][0][0].length, array[0][0][0][0].length, array[0][0][0][0][0].length, array[0][0][0][0][0][0].length}; } @Override public int[] getShape() { return shape; } @Override public Object get(int... indices) { return array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]]; } @Override public void set(Object value, int... indices) { this.array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]] = NumpyArrayFactory.toLong(value); } /** * Gets the underlying native array object. * * @return The underlying native array object. */ public long[][][][][][][] getArray() { return this.array; } @Override public boolean isFloatingPoint() { return false; } @Override public int numberOfBits() { return 64; } @Override public Object getRawArray() { return array; } @Override public NumpyArray wrapInnerSubsetArray(int... indices) { NumpyArray result = null; if (indices.length == 1) { result = NumpyArrayFactory.from(array[indices[0]]); } else if (indices.length == 2) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]]); } else if (indices.length == 3) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]]); } else if (indices.length == 4) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]]); } else if (indices.length == 5) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]]); } else if (indices.length == 6) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]]); } else { throw new NumpyOperationException("Invalid slice for array specified."); } return result; } @Override public NumpyArray transpose() { long[][][][][][][] result = new long[shape[6]][shape[5]][shape[4]][shape[3]][shape[2]][shape[1]][shape[0]]; for (int d0 = 0; d0 < this.shape[0]; d0++) { for (int d1 = 0; d1 < this.shape[1]; d1++) { for (int d2 = 0; d2 < this.shape[2]; d2++) { for (int d3 = 0; d3 < this.shape[3]; d3++) { for (int d4 = 0; d4 < this.shape[4]; d4++) { for (int d5 = 0; d5 < this.shape[5]; d5++) { for (int d6 = 0; d6 < this.shape[6]; d6++) { result[d6][d5][d4][d3][d2][d1][d0] = array[d0][d1][d2][d3][d4][d5][d6]; } } } } } } } return NumpyArrayFactory.from(result); } }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy/wrappers/Dim7Int8NumpyWrapper.java
/* * This file was automatically generated, don't edit it manually. */ package ai.sklearn4j.core.libraries.numpy.wrappers; import ai.sklearn4j.core.libraries.numpy.INumpyArrayWrapper; import ai.sklearn4j.core.libraries.numpy.NumpyArray; import ai.sklearn4j.core.libraries.numpy.NumpyArrayFactory; import ai.sklearn4j.core.libraries.numpy.NumpyOperationException; /** * A wrapper over a 7 dimensions byte array for NumpyArray class. */ public class Dim7Int8NumpyWrapper implements INumpyArrayWrapper { private final byte[][][][][][][] array; private final int[] shape; /** * Instantiate a new wrapper for 7 array. * * @param array The underlying native array object. */ public Dim7Int8NumpyWrapper(byte[][][][][][][] array) { this.array = array; this.shape = new int[]{array.length, array[0].length, array[0][0].length, array[0][0][0].length, array[0][0][0][0].length, array[0][0][0][0][0].length, array[0][0][0][0][0][0].length}; } @Override public int[] getShape() { return shape; } @Override public Object get(int... indices) { return array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]]; } @Override public void set(Object value, int... indices) { this.array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]] = NumpyArrayFactory.toByte(value); } /** * Gets the underlying native array object. * * @return The underlying native array object. */ public byte[][][][][][][] getArray() { return this.array; } @Override public boolean isFloatingPoint() { return false; } @Override public int numberOfBits() { return 8; } @Override public Object getRawArray() { return array; } @Override public NumpyArray wrapInnerSubsetArray(int... indices) { NumpyArray result = null; if (indices.length == 1) { result = NumpyArrayFactory.from(array[indices[0]]); } else if (indices.length == 2) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]]); } else if (indices.length == 3) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]]); } else if (indices.length == 4) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]]); } else if (indices.length == 5) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]]); } else if (indices.length == 6) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]]); } else { throw new NumpyOperationException("Invalid slice for array specified."); } return result; } @Override public NumpyArray transpose() { byte[][][][][][][] result = new byte[shape[6]][shape[5]][shape[4]][shape[3]][shape[2]][shape[1]][shape[0]]; for (int d0 = 0; d0 < this.shape[0]; d0++) { for (int d1 = 0; d1 < this.shape[1]; d1++) { for (int d2 = 0; d2 < this.shape[2]; d2++) { for (int d3 = 0; d3 < this.shape[3]; d3++) { for (int d4 = 0; d4 < this.shape[4]; d4++) { for (int d5 = 0; d5 < this.shape[5]; d5++) { for (int d6 = 0; d6 < this.shape[6]; d6++) { result[d6][d5][d4][d3][d2][d1][d0] = array[d0][d1][d2][d3][d4][d5][d6]; } } } } } } } return NumpyArrayFactory.from(result); } }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy/wrappers/Dim8DoubleNumpyWrapper.java
/* * This file was automatically generated, don't edit it manually. */ package ai.sklearn4j.core.libraries.numpy.wrappers; import ai.sklearn4j.core.libraries.numpy.INumpyArrayWrapper; import ai.sklearn4j.core.libraries.numpy.NumpyArray; import ai.sklearn4j.core.libraries.numpy.NumpyArrayFactory; import ai.sklearn4j.core.libraries.numpy.NumpyOperationException; /** * A wrapper over a 8 dimensions double array for NumpyArray class. */ public class Dim8DoubleNumpyWrapper implements INumpyArrayWrapper { private final double[][][][][][][][] array; private final int[] shape; /** * Instantiate a new wrapper for 8 array. * * @param array The underlying native array object. */ public Dim8DoubleNumpyWrapper(double[][][][][][][][] array) { this.array = array; this.shape = new int[]{array.length, array[0].length, array[0][0].length, array[0][0][0].length, array[0][0][0][0].length, array[0][0][0][0][0].length, array[0][0][0][0][0][0].length, array[0][0][0][0][0][0][0].length}; } @Override public int[] getShape() { return shape; } @Override public Object get(int... indices) { return array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]][indices[7]]; } @Override public void set(Object value, int... indices) { this.array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]][indices[7]] = NumpyArrayFactory.toDouble(value); } /** * Gets the underlying native array object. * * @return The underlying native array object. */ public double[][][][][][][][] getArray() { return this.array; } @Override public boolean isFloatingPoint() { return true; } @Override public int numberOfBits() { return 64; } @Override public Object getRawArray() { return array; } @Override public NumpyArray wrapInnerSubsetArray(int... indices) { NumpyArray result = null; if (indices.length == 1) { result = NumpyArrayFactory.from(array[indices[0]]); } else if (indices.length == 2) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]]); } else if (indices.length == 3) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]]); } else if (indices.length == 4) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]]); } else if (indices.length == 5) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]]); } else if (indices.length == 6) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]]); } else if (indices.length == 7) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]]); } else { throw new NumpyOperationException("Invalid slice for array specified."); } return result; } @Override public NumpyArray transpose() { double[][][][][][][][] result = new double[shape[7]][shape[6]][shape[5]][shape[4]][shape[3]][shape[2]][shape[1]][shape[0]]; for (int d0 = 0; d0 < this.shape[0]; d0++) { for (int d1 = 0; d1 < this.shape[1]; d1++) { for (int d2 = 0; d2 < this.shape[2]; d2++) { for (int d3 = 0; d3 < this.shape[3]; d3++) { for (int d4 = 0; d4 < this.shape[4]; d4++) { for (int d5 = 0; d5 < this.shape[5]; d5++) { for (int d6 = 0; d6 < this.shape[6]; d6++) { for (int d7 = 0; d7 < this.shape[7]; d7++) { result[d7][d6][d5][d4][d3][d2][d1][d0] = array[d0][d1][d2][d3][d4][d5][d6][d7]; } } } } } } } } return NumpyArrayFactory.from(result); } }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy/wrappers/Dim8FloatNumpyWrapper.java
/* * This file was automatically generated, don't edit it manually. */ package ai.sklearn4j.core.libraries.numpy.wrappers; import ai.sklearn4j.core.libraries.numpy.INumpyArrayWrapper; import ai.sklearn4j.core.libraries.numpy.NumpyArray; import ai.sklearn4j.core.libraries.numpy.NumpyArrayFactory; import ai.sklearn4j.core.libraries.numpy.NumpyOperationException; /** * A wrapper over a 8 dimensions float array for NumpyArray class. */ public class Dim8FloatNumpyWrapper implements INumpyArrayWrapper { private final float[][][][][][][][] array; private final int[] shape; /** * Instantiate a new wrapper for 8 array. * * @param array The underlying native array object. */ public Dim8FloatNumpyWrapper(float[][][][][][][][] array) { this.array = array; this.shape = new int[]{array.length, array[0].length, array[0][0].length, array[0][0][0].length, array[0][0][0][0].length, array[0][0][0][0][0].length, array[0][0][0][0][0][0].length, array[0][0][0][0][0][0][0].length}; } @Override public int[] getShape() { return shape; } @Override public Object get(int... indices) { return array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]][indices[7]]; } @Override public void set(Object value, int... indices) { this.array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]][indices[7]] = NumpyArrayFactory.toFloat(value); } /** * Gets the underlying native array object. * * @return The underlying native array object. */ public float[][][][][][][][] getArray() { return this.array; } @Override public boolean isFloatingPoint() { return true; } @Override public int numberOfBits() { return 32; } @Override public Object getRawArray() { return array; } @Override public NumpyArray wrapInnerSubsetArray(int... indices) { NumpyArray result = null; if (indices.length == 1) { result = NumpyArrayFactory.from(array[indices[0]]); } else if (indices.length == 2) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]]); } else if (indices.length == 3) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]]); } else if (indices.length == 4) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]]); } else if (indices.length == 5) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]]); } else if (indices.length == 6) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]]); } else if (indices.length == 7) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]]); } else { throw new NumpyOperationException("Invalid slice for array specified."); } return result; } @Override public NumpyArray transpose() { float[][][][][][][][] result = new float[shape[7]][shape[6]][shape[5]][shape[4]][shape[3]][shape[2]][shape[1]][shape[0]]; for (int d0 = 0; d0 < this.shape[0]; d0++) { for (int d1 = 0; d1 < this.shape[1]; d1++) { for (int d2 = 0; d2 < this.shape[2]; d2++) { for (int d3 = 0; d3 < this.shape[3]; d3++) { for (int d4 = 0; d4 < this.shape[4]; d4++) { for (int d5 = 0; d5 < this.shape[5]; d5++) { for (int d6 = 0; d6 < this.shape[6]; d6++) { for (int d7 = 0; d7 < this.shape[7]; d7++) { result[d7][d6][d5][d4][d3][d2][d1][d0] = array[d0][d1][d2][d3][d4][d5][d6][d7]; } } } } } } } } return NumpyArrayFactory.from(result); } }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy/wrappers/Dim8Int16NumpyWrapper.java
/* * This file was automatically generated, don't edit it manually. */ package ai.sklearn4j.core.libraries.numpy.wrappers; import ai.sklearn4j.core.libraries.numpy.INumpyArrayWrapper; import ai.sklearn4j.core.libraries.numpy.NumpyArray; import ai.sklearn4j.core.libraries.numpy.NumpyArrayFactory; import ai.sklearn4j.core.libraries.numpy.NumpyOperationException; /** * A wrapper over a 8 dimensions short array for NumpyArray class. */ public class Dim8Int16NumpyWrapper implements INumpyArrayWrapper { private final short[][][][][][][][] array; private final int[] shape; /** * Instantiate a new wrapper for 8 array. * * @param array The underlying native array object. */ public Dim8Int16NumpyWrapper(short[][][][][][][][] array) { this.array = array; this.shape = new int[]{array.length, array[0].length, array[0][0].length, array[0][0][0].length, array[0][0][0][0].length, array[0][0][0][0][0].length, array[0][0][0][0][0][0].length, array[0][0][0][0][0][0][0].length}; } @Override public int[] getShape() { return shape; } @Override public Object get(int... indices) { return array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]][indices[7]]; } @Override public void set(Object value, int... indices) { this.array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]][indices[7]] = NumpyArrayFactory.toShort(value); } /** * Gets the underlying native array object. * * @return The underlying native array object. */ public short[][][][][][][][] getArray() { return this.array; } @Override public boolean isFloatingPoint() { return false; } @Override public int numberOfBits() { return 16; } @Override public Object getRawArray() { return array; } @Override public NumpyArray wrapInnerSubsetArray(int... indices) { NumpyArray result = null; if (indices.length == 1) { result = NumpyArrayFactory.from(array[indices[0]]); } else if (indices.length == 2) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]]); } else if (indices.length == 3) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]]); } else if (indices.length == 4) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]]); } else if (indices.length == 5) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]]); } else if (indices.length == 6) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]]); } else if (indices.length == 7) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]]); } else { throw new NumpyOperationException("Invalid slice for array specified."); } return result; } @Override public NumpyArray transpose() { short[][][][][][][][] result = new short[shape[7]][shape[6]][shape[5]][shape[4]][shape[3]][shape[2]][shape[1]][shape[0]]; for (int d0 = 0; d0 < this.shape[0]; d0++) { for (int d1 = 0; d1 < this.shape[1]; d1++) { for (int d2 = 0; d2 < this.shape[2]; d2++) { for (int d3 = 0; d3 < this.shape[3]; d3++) { for (int d4 = 0; d4 < this.shape[4]; d4++) { for (int d5 = 0; d5 < this.shape[5]; d5++) { for (int d6 = 0; d6 < this.shape[6]; d6++) { for (int d7 = 0; d7 < this.shape[7]; d7++) { result[d7][d6][d5][d4][d3][d2][d1][d0] = array[d0][d1][d2][d3][d4][d5][d6][d7]; } } } } } } } } return NumpyArrayFactory.from(result); } }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy/wrappers/Dim8Int32NumpyWrapper.java
/* * This file was automatically generated, don't edit it manually. */ package ai.sklearn4j.core.libraries.numpy.wrappers; import ai.sklearn4j.core.libraries.numpy.INumpyArrayWrapper; import ai.sklearn4j.core.libraries.numpy.NumpyArray; import ai.sklearn4j.core.libraries.numpy.NumpyArrayFactory; import ai.sklearn4j.core.libraries.numpy.NumpyOperationException; /** * A wrapper over a 8 dimensions int array for NumpyArray class. */ public class Dim8Int32NumpyWrapper implements INumpyArrayWrapper { private final int[][][][][][][][] array; private final int[] shape; /** * Instantiate a new wrapper for 8 array. * * @param array The underlying native array object. */ public Dim8Int32NumpyWrapper(int[][][][][][][][] array) { this.array = array; this.shape = new int[]{array.length, array[0].length, array[0][0].length, array[0][0][0].length, array[0][0][0][0].length, array[0][0][0][0][0].length, array[0][0][0][0][0][0].length, array[0][0][0][0][0][0][0].length}; } @Override public int[] getShape() { return shape; } @Override public Object get(int... indices) { return array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]][indices[7]]; } @Override public void set(Object value, int... indices) { this.array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]][indices[7]] = NumpyArrayFactory.toInteger(value); } /** * Gets the underlying native array object. * * @return The underlying native array object. */ public int[][][][][][][][] getArray() { return this.array; } @Override public boolean isFloatingPoint() { return false; } @Override public int numberOfBits() { return 32; } @Override public Object getRawArray() { return array; } @Override public NumpyArray wrapInnerSubsetArray(int... indices) { NumpyArray result = null; if (indices.length == 1) { result = NumpyArrayFactory.from(array[indices[0]]); } else if (indices.length == 2) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]]); } else if (indices.length == 3) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]]); } else if (indices.length == 4) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]]); } else if (indices.length == 5) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]]); } else if (indices.length == 6) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]]); } else if (indices.length == 7) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]]); } else { throw new NumpyOperationException("Invalid slice for array specified."); } return result; } @Override public NumpyArray transpose() { int[][][][][][][][] result = new int[shape[7]][shape[6]][shape[5]][shape[4]][shape[3]][shape[2]][shape[1]][shape[0]]; for (int d0 = 0; d0 < this.shape[0]; d0++) { for (int d1 = 0; d1 < this.shape[1]; d1++) { for (int d2 = 0; d2 < this.shape[2]; d2++) { for (int d3 = 0; d3 < this.shape[3]; d3++) { for (int d4 = 0; d4 < this.shape[4]; d4++) { for (int d5 = 0; d5 < this.shape[5]; d5++) { for (int d6 = 0; d6 < this.shape[6]; d6++) { for (int d7 = 0; d7 < this.shape[7]; d7++) { result[d7][d6][d5][d4][d3][d2][d1][d0] = array[d0][d1][d2][d3][d4][d5][d6][d7]; } } } } } } } } return NumpyArrayFactory.from(result); } }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy/wrappers/Dim8Int64NumpyWrapper.java
/* * This file was automatically generated, don't edit it manually. */ package ai.sklearn4j.core.libraries.numpy.wrappers; import ai.sklearn4j.core.libraries.numpy.INumpyArrayWrapper; import ai.sklearn4j.core.libraries.numpy.NumpyArray; import ai.sklearn4j.core.libraries.numpy.NumpyArrayFactory; import ai.sklearn4j.core.libraries.numpy.NumpyOperationException; /** * A wrapper over a 8 dimensions long array for NumpyArray class. */ public class Dim8Int64NumpyWrapper implements INumpyArrayWrapper { private final long[][][][][][][][] array; private final int[] shape; /** * Instantiate a new wrapper for 8 array. * * @param array The underlying native array object. */ public Dim8Int64NumpyWrapper(long[][][][][][][][] array) { this.array = array; this.shape = new int[]{array.length, array[0].length, array[0][0].length, array[0][0][0].length, array[0][0][0][0].length, array[0][0][0][0][0].length, array[0][0][0][0][0][0].length, array[0][0][0][0][0][0][0].length}; } @Override public int[] getShape() { return shape; } @Override public Object get(int... indices) { return array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]][indices[7]]; } @Override public void set(Object value, int... indices) { this.array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]][indices[7]] = NumpyArrayFactory.toLong(value); } /** * Gets the underlying native array object. * * @return The underlying native array object. */ public long[][][][][][][][] getArray() { return this.array; } @Override public boolean isFloatingPoint() { return false; } @Override public int numberOfBits() { return 64; } @Override public Object getRawArray() { return array; } @Override public NumpyArray wrapInnerSubsetArray(int... indices) { NumpyArray result = null; if (indices.length == 1) { result = NumpyArrayFactory.from(array[indices[0]]); } else if (indices.length == 2) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]]); } else if (indices.length == 3) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]]); } else if (indices.length == 4) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]]); } else if (indices.length == 5) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]]); } else if (indices.length == 6) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]]); } else if (indices.length == 7) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]]); } else { throw new NumpyOperationException("Invalid slice for array specified."); } return result; } @Override public NumpyArray transpose() { long[][][][][][][][] result = new long[shape[7]][shape[6]][shape[5]][shape[4]][shape[3]][shape[2]][shape[1]][shape[0]]; for (int d0 = 0; d0 < this.shape[0]; d0++) { for (int d1 = 0; d1 < this.shape[1]; d1++) { for (int d2 = 0; d2 < this.shape[2]; d2++) { for (int d3 = 0; d3 < this.shape[3]; d3++) { for (int d4 = 0; d4 < this.shape[4]; d4++) { for (int d5 = 0; d5 < this.shape[5]; d5++) { for (int d6 = 0; d6 < this.shape[6]; d6++) { for (int d7 = 0; d7 < this.shape[7]; d7++) { result[d7][d6][d5][d4][d3][d2][d1][d0] = array[d0][d1][d2][d3][d4][d5][d6][d7]; } } } } } } } } return NumpyArrayFactory.from(result); } }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy/wrappers/Dim8Int8NumpyWrapper.java
/* * This file was automatically generated, don't edit it manually. */ package ai.sklearn4j.core.libraries.numpy.wrappers; import ai.sklearn4j.core.libraries.numpy.INumpyArrayWrapper; import ai.sklearn4j.core.libraries.numpy.NumpyArray; import ai.sklearn4j.core.libraries.numpy.NumpyArrayFactory; import ai.sklearn4j.core.libraries.numpy.NumpyOperationException; /** * A wrapper over a 8 dimensions byte array for NumpyArray class. */ public class Dim8Int8NumpyWrapper implements INumpyArrayWrapper { private final byte[][][][][][][][] array; private final int[] shape; /** * Instantiate a new wrapper for 8 array. * * @param array The underlying native array object. */ public Dim8Int8NumpyWrapper(byte[][][][][][][][] array) { this.array = array; this.shape = new int[]{array.length, array[0].length, array[0][0].length, array[0][0][0].length, array[0][0][0][0].length, array[0][0][0][0][0].length, array[0][0][0][0][0][0].length, array[0][0][0][0][0][0][0].length}; } @Override public int[] getShape() { return shape; } @Override public Object get(int... indices) { return array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]][indices[7]]; } @Override public void set(Object value, int... indices) { this.array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]][indices[7]] = NumpyArrayFactory.toByte(value); } /** * Gets the underlying native array object. * * @return The underlying native array object. */ public byte[][][][][][][][] getArray() { return this.array; } @Override public boolean isFloatingPoint() { return false; } @Override public int numberOfBits() { return 8; } @Override public Object getRawArray() { return array; } @Override public NumpyArray wrapInnerSubsetArray(int... indices) { NumpyArray result = null; if (indices.length == 1) { result = NumpyArrayFactory.from(array[indices[0]]); } else if (indices.length == 2) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]]); } else if (indices.length == 3) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]]); } else if (indices.length == 4) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]]); } else if (indices.length == 5) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]]); } else if (indices.length == 6) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]]); } else if (indices.length == 7) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]]); } else { throw new NumpyOperationException("Invalid slice for array specified."); } return result; } @Override public NumpyArray transpose() { byte[][][][][][][][] result = new byte[shape[7]][shape[6]][shape[5]][shape[4]][shape[3]][shape[2]][shape[1]][shape[0]]; for (int d0 = 0; d0 < this.shape[0]; d0++) { for (int d1 = 0; d1 < this.shape[1]; d1++) { for (int d2 = 0; d2 < this.shape[2]; d2++) { for (int d3 = 0; d3 < this.shape[3]; d3++) { for (int d4 = 0; d4 < this.shape[4]; d4++) { for (int d5 = 0; d5 < this.shape[5]; d5++) { for (int d6 = 0; d6 < this.shape[6]; d6++) { for (int d7 = 0; d7 < this.shape[7]; d7++) { result[d7][d6][d5][d4][d3][d2][d1][d0] = array[d0][d1][d2][d3][d4][d5][d6][d7]; } } } } } } } } return NumpyArrayFactory.from(result); } }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy/wrappers/Dim9DoubleNumpyWrapper.java
/* * This file was automatically generated, don't edit it manually. */ package ai.sklearn4j.core.libraries.numpy.wrappers; import ai.sklearn4j.core.libraries.numpy.INumpyArrayWrapper; import ai.sklearn4j.core.libraries.numpy.NumpyArray; import ai.sklearn4j.core.libraries.numpy.NumpyArrayFactory; import ai.sklearn4j.core.libraries.numpy.NumpyOperationException; /** * A wrapper over a 9 dimensions double array for NumpyArray class. */ public class Dim9DoubleNumpyWrapper implements INumpyArrayWrapper { private final double[][][][][][][][][] array; private final int[] shape; /** * Instantiate a new wrapper for 9 array. * * @param array The underlying native array object. */ public Dim9DoubleNumpyWrapper(double[][][][][][][][][] array) { this.array = array; this.shape = new int[]{array.length, array[0].length, array[0][0].length, array[0][0][0].length, array[0][0][0][0].length, array[0][0][0][0][0].length, array[0][0][0][0][0][0].length, array[0][0][0][0][0][0][0].length, array[0][0][0][0][0][0][0][0].length}; } @Override public int[] getShape() { return shape; } @Override public Object get(int... indices) { return array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]][indices[7]][indices[8]]; } @Override public void set(Object value, int... indices) { this.array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]][indices[7]][indices[8]] = NumpyArrayFactory.toDouble(value); } /** * Gets the underlying native array object. * * @return The underlying native array object. */ public double[][][][][][][][][] getArray() { return this.array; } @Override public boolean isFloatingPoint() { return true; } @Override public int numberOfBits() { return 64; } @Override public Object getRawArray() { return array; } @Override public NumpyArray wrapInnerSubsetArray(int... indices) { NumpyArray result = null; if (indices.length == 1) { result = NumpyArrayFactory.from(array[indices[0]]); } else if (indices.length == 2) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]]); } else if (indices.length == 3) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]]); } else if (indices.length == 4) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]]); } else if (indices.length == 5) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]]); } else if (indices.length == 6) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]]); } else if (indices.length == 7) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]]); } else if (indices.length == 8) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]][indices[7]]); } else { throw new NumpyOperationException("Invalid slice for array specified."); } return result; } @Override public NumpyArray transpose() { double[][][][][][][][][] result = new double[shape[8]][shape[7]][shape[6]][shape[5]][shape[4]][shape[3]][shape[2]][shape[1]][shape[0]]; for (int d0 = 0; d0 < this.shape[0]; d0++) { for (int d1 = 0; d1 < this.shape[1]; d1++) { for (int d2 = 0; d2 < this.shape[2]; d2++) { for (int d3 = 0; d3 < this.shape[3]; d3++) { for (int d4 = 0; d4 < this.shape[4]; d4++) { for (int d5 = 0; d5 < this.shape[5]; d5++) { for (int d6 = 0; d6 < this.shape[6]; d6++) { for (int d7 = 0; d7 < this.shape[7]; d7++) { for (int d8 = 0; d8 < this.shape[8]; d8++) { result[d8][d7][d6][d5][d4][d3][d2][d1][d0] = array[d0][d1][d2][d3][d4][d5][d6][d7][d8]; } } } } } } } } } return NumpyArrayFactory.from(result); } }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy/wrappers/Dim9FloatNumpyWrapper.java
/* * This file was automatically generated, don't edit it manually. */ package ai.sklearn4j.core.libraries.numpy.wrappers; import ai.sklearn4j.core.libraries.numpy.INumpyArrayWrapper; import ai.sklearn4j.core.libraries.numpy.NumpyArray; import ai.sklearn4j.core.libraries.numpy.NumpyArrayFactory; import ai.sklearn4j.core.libraries.numpy.NumpyOperationException; /** * A wrapper over a 9 dimensions float array for NumpyArray class. */ public class Dim9FloatNumpyWrapper implements INumpyArrayWrapper { private final float[][][][][][][][][] array; private final int[] shape; /** * Instantiate a new wrapper for 9 array. * * @param array The underlying native array object. */ public Dim9FloatNumpyWrapper(float[][][][][][][][][] array) { this.array = array; this.shape = new int[]{array.length, array[0].length, array[0][0].length, array[0][0][0].length, array[0][0][0][0].length, array[0][0][0][0][0].length, array[0][0][0][0][0][0].length, array[0][0][0][0][0][0][0].length, array[0][0][0][0][0][0][0][0].length}; } @Override public int[] getShape() { return shape; } @Override public Object get(int... indices) { return array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]][indices[7]][indices[8]]; } @Override public void set(Object value, int... indices) { this.array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]][indices[7]][indices[8]] = NumpyArrayFactory.toFloat(value); } /** * Gets the underlying native array object. * * @return The underlying native array object. */ public float[][][][][][][][][] getArray() { return this.array; } @Override public boolean isFloatingPoint() { return true; } @Override public int numberOfBits() { return 32; } @Override public Object getRawArray() { return array; } @Override public NumpyArray wrapInnerSubsetArray(int... indices) { NumpyArray result = null; if (indices.length == 1) { result = NumpyArrayFactory.from(array[indices[0]]); } else if (indices.length == 2) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]]); } else if (indices.length == 3) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]]); } else if (indices.length == 4) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]]); } else if (indices.length == 5) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]]); } else if (indices.length == 6) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]]); } else if (indices.length == 7) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]]); } else if (indices.length == 8) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]][indices[7]]); } else { throw new NumpyOperationException("Invalid slice for array specified."); } return result; } @Override public NumpyArray transpose() { float[][][][][][][][][] result = new float[shape[8]][shape[7]][shape[6]][shape[5]][shape[4]][shape[3]][shape[2]][shape[1]][shape[0]]; for (int d0 = 0; d0 < this.shape[0]; d0++) { for (int d1 = 0; d1 < this.shape[1]; d1++) { for (int d2 = 0; d2 < this.shape[2]; d2++) { for (int d3 = 0; d3 < this.shape[3]; d3++) { for (int d4 = 0; d4 < this.shape[4]; d4++) { for (int d5 = 0; d5 < this.shape[5]; d5++) { for (int d6 = 0; d6 < this.shape[6]; d6++) { for (int d7 = 0; d7 < this.shape[7]; d7++) { for (int d8 = 0; d8 < this.shape[8]; d8++) { result[d8][d7][d6][d5][d4][d3][d2][d1][d0] = array[d0][d1][d2][d3][d4][d5][d6][d7][d8]; } } } } } } } } } return NumpyArrayFactory.from(result); } }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy/wrappers/Dim9Int16NumpyWrapper.java
/* * This file was automatically generated, don't edit it manually. */ package ai.sklearn4j.core.libraries.numpy.wrappers; import ai.sklearn4j.core.libraries.numpy.INumpyArrayWrapper; import ai.sklearn4j.core.libraries.numpy.NumpyArray; import ai.sklearn4j.core.libraries.numpy.NumpyArrayFactory; import ai.sklearn4j.core.libraries.numpy.NumpyOperationException; /** * A wrapper over a 9 dimensions short array for NumpyArray class. */ public class Dim9Int16NumpyWrapper implements INumpyArrayWrapper { private final short[][][][][][][][][] array; private final int[] shape; /** * Instantiate a new wrapper for 9 array. * * @param array The underlying native array object. */ public Dim9Int16NumpyWrapper(short[][][][][][][][][] array) { this.array = array; this.shape = new int[]{array.length, array[0].length, array[0][0].length, array[0][0][0].length, array[0][0][0][0].length, array[0][0][0][0][0].length, array[0][0][0][0][0][0].length, array[0][0][0][0][0][0][0].length, array[0][0][0][0][0][0][0][0].length}; } @Override public int[] getShape() { return shape; } @Override public Object get(int... indices) { return array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]][indices[7]][indices[8]]; } @Override public void set(Object value, int... indices) { this.array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]][indices[7]][indices[8]] = NumpyArrayFactory.toShort(value); } /** * Gets the underlying native array object. * * @return The underlying native array object. */ public short[][][][][][][][][] getArray() { return this.array; } @Override public boolean isFloatingPoint() { return false; } @Override public int numberOfBits() { return 16; } @Override public Object getRawArray() { return array; } @Override public NumpyArray wrapInnerSubsetArray(int... indices) { NumpyArray result = null; if (indices.length == 1) { result = NumpyArrayFactory.from(array[indices[0]]); } else if (indices.length == 2) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]]); } else if (indices.length == 3) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]]); } else if (indices.length == 4) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]]); } else if (indices.length == 5) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]]); } else if (indices.length == 6) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]]); } else if (indices.length == 7) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]]); } else if (indices.length == 8) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]][indices[7]]); } else { throw new NumpyOperationException("Invalid slice for array specified."); } return result; } @Override public NumpyArray transpose() { short[][][][][][][][][] result = new short[shape[8]][shape[7]][shape[6]][shape[5]][shape[4]][shape[3]][shape[2]][shape[1]][shape[0]]; for (int d0 = 0; d0 < this.shape[0]; d0++) { for (int d1 = 0; d1 < this.shape[1]; d1++) { for (int d2 = 0; d2 < this.shape[2]; d2++) { for (int d3 = 0; d3 < this.shape[3]; d3++) { for (int d4 = 0; d4 < this.shape[4]; d4++) { for (int d5 = 0; d5 < this.shape[5]; d5++) { for (int d6 = 0; d6 < this.shape[6]; d6++) { for (int d7 = 0; d7 < this.shape[7]; d7++) { for (int d8 = 0; d8 < this.shape[8]; d8++) { result[d8][d7][d6][d5][d4][d3][d2][d1][d0] = array[d0][d1][d2][d3][d4][d5][d6][d7][d8]; } } } } } } } } } return NumpyArrayFactory.from(result); } }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy/wrappers/Dim9Int32NumpyWrapper.java
/* * This file was automatically generated, don't edit it manually. */ package ai.sklearn4j.core.libraries.numpy.wrappers; import ai.sklearn4j.core.libraries.numpy.INumpyArrayWrapper; import ai.sklearn4j.core.libraries.numpy.NumpyArray; import ai.sklearn4j.core.libraries.numpy.NumpyArrayFactory; import ai.sklearn4j.core.libraries.numpy.NumpyOperationException; /** * A wrapper over a 9 dimensions int array for NumpyArray class. */ public class Dim9Int32NumpyWrapper implements INumpyArrayWrapper { private final int[][][][][][][][][] array; private final int[] shape; /** * Instantiate a new wrapper for 9 array. * * @param array The underlying native array object. */ public Dim9Int32NumpyWrapper(int[][][][][][][][][] array) { this.array = array; this.shape = new int[]{array.length, array[0].length, array[0][0].length, array[0][0][0].length, array[0][0][0][0].length, array[0][0][0][0][0].length, array[0][0][0][0][0][0].length, array[0][0][0][0][0][0][0].length, array[0][0][0][0][0][0][0][0].length}; } @Override public int[] getShape() { return shape; } @Override public Object get(int... indices) { return array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]][indices[7]][indices[8]]; } @Override public void set(Object value, int... indices) { this.array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]][indices[7]][indices[8]] = NumpyArrayFactory.toInteger(value); } /** * Gets the underlying native array object. * * @return The underlying native array object. */ public int[][][][][][][][][] getArray() { return this.array; } @Override public boolean isFloatingPoint() { return false; } @Override public int numberOfBits() { return 32; } @Override public Object getRawArray() { return array; } @Override public NumpyArray wrapInnerSubsetArray(int... indices) { NumpyArray result = null; if (indices.length == 1) { result = NumpyArrayFactory.from(array[indices[0]]); } else if (indices.length == 2) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]]); } else if (indices.length == 3) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]]); } else if (indices.length == 4) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]]); } else if (indices.length == 5) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]]); } else if (indices.length == 6) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]]); } else if (indices.length == 7) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]]); } else if (indices.length == 8) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]][indices[7]]); } else { throw new NumpyOperationException("Invalid slice for array specified."); } return result; } @Override public NumpyArray transpose() { int[][][][][][][][][] result = new int[shape[8]][shape[7]][shape[6]][shape[5]][shape[4]][shape[3]][shape[2]][shape[1]][shape[0]]; for (int d0 = 0; d0 < this.shape[0]; d0++) { for (int d1 = 0; d1 < this.shape[1]; d1++) { for (int d2 = 0; d2 < this.shape[2]; d2++) { for (int d3 = 0; d3 < this.shape[3]; d3++) { for (int d4 = 0; d4 < this.shape[4]; d4++) { for (int d5 = 0; d5 < this.shape[5]; d5++) { for (int d6 = 0; d6 < this.shape[6]; d6++) { for (int d7 = 0; d7 < this.shape[7]; d7++) { for (int d8 = 0; d8 < this.shape[8]; d8++) { result[d8][d7][d6][d5][d4][d3][d2][d1][d0] = array[d0][d1][d2][d3][d4][d5][d6][d7][d8]; } } } } } } } } } return NumpyArrayFactory.from(result); } }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy/wrappers/Dim9Int64NumpyWrapper.java
/* * This file was automatically generated, don't edit it manually. */ package ai.sklearn4j.core.libraries.numpy.wrappers; import ai.sklearn4j.core.libraries.numpy.INumpyArrayWrapper; import ai.sklearn4j.core.libraries.numpy.NumpyArray; import ai.sklearn4j.core.libraries.numpy.NumpyArrayFactory; import ai.sklearn4j.core.libraries.numpy.NumpyOperationException; /** * A wrapper over a 9 dimensions long array for NumpyArray class. */ public class Dim9Int64NumpyWrapper implements INumpyArrayWrapper { private final long[][][][][][][][][] array; private final int[] shape; /** * Instantiate a new wrapper for 9 array. * * @param array The underlying native array object. */ public Dim9Int64NumpyWrapper(long[][][][][][][][][] array) { this.array = array; this.shape = new int[]{array.length, array[0].length, array[0][0].length, array[0][0][0].length, array[0][0][0][0].length, array[0][0][0][0][0].length, array[0][0][0][0][0][0].length, array[0][0][0][0][0][0][0].length, array[0][0][0][0][0][0][0][0].length}; } @Override public int[] getShape() { return shape; } @Override public Object get(int... indices) { return array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]][indices[7]][indices[8]]; } @Override public void set(Object value, int... indices) { this.array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]][indices[7]][indices[8]] = NumpyArrayFactory.toLong(value); } /** * Gets the underlying native array object. * * @return The underlying native array object. */ public long[][][][][][][][][] getArray() { return this.array; } @Override public boolean isFloatingPoint() { return false; } @Override public int numberOfBits() { return 64; } @Override public Object getRawArray() { return array; } @Override public NumpyArray wrapInnerSubsetArray(int... indices) { NumpyArray result = null; if (indices.length == 1) { result = NumpyArrayFactory.from(array[indices[0]]); } else if (indices.length == 2) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]]); } else if (indices.length == 3) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]]); } else if (indices.length == 4) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]]); } else if (indices.length == 5) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]]); } else if (indices.length == 6) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]]); } else if (indices.length == 7) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]]); } else if (indices.length == 8) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]][indices[7]]); } else { throw new NumpyOperationException("Invalid slice for array specified."); } return result; } @Override public NumpyArray transpose() { long[][][][][][][][][] result = new long[shape[8]][shape[7]][shape[6]][shape[5]][shape[4]][shape[3]][shape[2]][shape[1]][shape[0]]; for (int d0 = 0; d0 < this.shape[0]; d0++) { for (int d1 = 0; d1 < this.shape[1]; d1++) { for (int d2 = 0; d2 < this.shape[2]; d2++) { for (int d3 = 0; d3 < this.shape[3]; d3++) { for (int d4 = 0; d4 < this.shape[4]; d4++) { for (int d5 = 0; d5 < this.shape[5]; d5++) { for (int d6 = 0; d6 < this.shape[6]; d6++) { for (int d7 = 0; d7 < this.shape[7]; d7++) { for (int d8 = 0; d8 < this.shape[8]; d8++) { result[d8][d7][d6][d5][d4][d3][d2][d1][d0] = array[d0][d1][d2][d3][d4][d5][d6][d7][d8]; } } } } } } } } } return NumpyArrayFactory.from(result); } }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/libraries/numpy/wrappers/Dim9Int8NumpyWrapper.java
/* * This file was automatically generated, don't edit it manually. */ package ai.sklearn4j.core.libraries.numpy.wrappers; import ai.sklearn4j.core.libraries.numpy.INumpyArrayWrapper; import ai.sklearn4j.core.libraries.numpy.NumpyArray; import ai.sklearn4j.core.libraries.numpy.NumpyArrayFactory; import ai.sklearn4j.core.libraries.numpy.NumpyOperationException; /** * A wrapper over a 9 dimensions byte array for NumpyArray class. */ public class Dim9Int8NumpyWrapper implements INumpyArrayWrapper { private final byte[][][][][][][][][] array; private final int[] shape; /** * Instantiate a new wrapper for 9 array. * * @param array The underlying native array object. */ public Dim9Int8NumpyWrapper(byte[][][][][][][][][] array) { this.array = array; this.shape = new int[]{array.length, array[0].length, array[0][0].length, array[0][0][0].length, array[0][0][0][0].length, array[0][0][0][0][0].length, array[0][0][0][0][0][0].length, array[0][0][0][0][0][0][0].length, array[0][0][0][0][0][0][0][0].length}; } @Override public int[] getShape() { return shape; } @Override public Object get(int... indices) { return array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]][indices[7]][indices[8]]; } @Override public void set(Object value, int... indices) { this.array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]][indices[7]][indices[8]] = NumpyArrayFactory.toByte(value); } /** * Gets the underlying native array object. * * @return The underlying native array object. */ public byte[][][][][][][][][] getArray() { return this.array; } @Override public boolean isFloatingPoint() { return false; } @Override public int numberOfBits() { return 8; } @Override public Object getRawArray() { return array; } @Override public NumpyArray wrapInnerSubsetArray(int... indices) { NumpyArray result = null; if (indices.length == 1) { result = NumpyArrayFactory.from(array[indices[0]]); } else if (indices.length == 2) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]]); } else if (indices.length == 3) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]]); } else if (indices.length == 4) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]]); } else if (indices.length == 5) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]]); } else if (indices.length == 6) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]]); } else if (indices.length == 7) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]]); } else if (indices.length == 8) { result = NumpyArrayFactory.from(array[indices[0]][indices[1]][indices[2]][indices[3]][indices[4]][indices[5]][indices[6]][indices[7]]); } else { throw new NumpyOperationException("Invalid slice for array specified."); } return result; } @Override public NumpyArray transpose() { byte[][][][][][][][][] result = new byte[shape[8]][shape[7]][shape[6]][shape[5]][shape[4]][shape[3]][shape[2]][shape[1]][shape[0]]; for (int d0 = 0; d0 < this.shape[0]; d0++) { for (int d1 = 0; d1 < this.shape[1]; d1++) { for (int d2 = 0; d2 < this.shape[2]; d2++) { for (int d3 = 0; d3 < this.shape[3]; d3++) { for (int d4 = 0; d4 < this.shape[4]; d4++) { for (int d5 = 0; d5 < this.shape[5]; d5++) { for (int d6 = 0; d6 < this.shape[6]; d6++) { for (int d7 = 0; d7 < this.shape[7]; d7++) { for (int d8 = 0; d8 < this.shape[8]; d8++) { result[d8][d7][d6][d5][d4][d3][d2][d1][d0] = array[d0][d1][d2][d3][d4][d5][d6][d7][d8]; } } } } } } } } } return NumpyArrayFactory.from(result); } }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/packaging/BinaryModelPackage.java
package ai.sklearn4j.core.packaging; import ai.sklearn4j.core.ScikitLearnCoreException; import ai.sklearn4j.core.libraries.numpy.NumpyArray; import ai.sklearn4j.core.libraries.numpy.NumpyArrayFactory; import java.io.*; import java.lang.reflect.Array; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; /** * The python package (sklearn4x) implements a class named BinaryBuffer that saves the python objects * in a binary format. BinaryModelPackage is its counterpart to load these files (or stream) in other * languages. */ public class BinaryModelPackage { /** * Constant value to denote the element is of type byte. */ private static final int ELEMENT_TYPE_BYTE = 0x01; /** * Constant value to denote the element is of type short. */ private static final int ELEMENT_TYPE_SHORT = 0x02; /** * Constant value to denote the element is of type int. */ private static final int ELEMENT_TYPE_INT = 0x04; /** * Constant value to denote the element is of type long. */ private static final int ELEMENT_TYPE_LONG = 0x08; /** * Constant value to denote the element is of type unsigned byte. */ private static final int ELEMENT_TYPE_UNSIGNED_BYTE = 0x11; /** * Constant value to denote the element is of type unsigned short. */ private static final int ELEMENT_TYPE_UNSIGNED_SHORT = 0x12; /** * Constant value to denote the element is of type unsigned int. */ private static final int ELEMENT_TYPE_UNSIGNED_INT = 0x14; /** * Constant value to denote the element is of type unsigned long. */ private static final int ELEMENT_TYPE_UNSIGNED_LONG = 0x18; /** * Constant value to denote the element is of type float. */ private static final int ELEMENT_TYPE_FLOAT = 0x20; /** * Constant value to denote the element is of type double. */ private static final int ELEMENT_TYPE_DOUBLE = 0x21; /** * Constant value to denote the element is of type string. */ private static final int ELEMENT_TYPE_STRING = 0x30; /** * Constant value to denote the element is of type list. */ private static final int ELEMENT_TYPE_LIST = 0x40; /** * Constant value to denote the element is of type dictionary. */ private static final int ELEMENT_TYPE_DICTIONARY = 0x41; /** * Constant value to denote the element is of type numpy array. */ private static final int ELEMENT_TYPE_NUMPY_ARRAY = 0x42; /** * Constant value to denote the element is of type string array. */ private static final int ELEMENT_TYPE_STRING_ARRAY = 0x43; /** * Constant value to denote the element is null. */ private static final int ELEMENT_TYPE_NULL = 0x10; /** * The input stream from which the buffer is loading. */ private final InputStream stream; /** * Instantiate a new BinaryModelPackage object. * * @param stream The input stream from which the buffer is loading. */ private BinaryModelPackage(InputStream stream) { this.stream = stream; } /** * Creates a new BinaryModelPackage that reads from a given file. * * @param path Path to the file to be read. * @return A BinaryModelPackage instance to read the package file. */ public static BinaryModelPackage fromFile(String path) { try { InputStream stream = new BufferedInputStream(new FileInputStream(path)); byte[] data = new byte[stream.available()]; stream.read(data); BinaryModelPackage result = fromStream(new ByteArrayInputStream(data)); stream.close(); return result; } catch (IOException ex) { throw new ScikitLearnCoreException("An error occurred while loading a package from file:\n" + ex.getMessage()); } } /** * Creates a new BinaryModelPackage that reads from a given stream. This method is useful to * load the files from a custom-made package or an encrypted one. * * @param stream The input stream that should be loaded. It is recommended to use a buffered stream. * @return A BinaryModelPackage instance to read the package stream. */ public static BinaryModelPackage fromStream(InputStream stream) { return new BinaryModelPackage(stream); } /** * Reads a byte from the stream. * * @return A byte value stored in the stream. */ public byte readByte() { int size = 1; byte[] data = readBuffer(size); return data[0]; } /** * Reads a 16-bits integer from the stream. The values are stored in little endian formats. * * @return A short value stored in the stream. */ public short readShort() { int size = 2; int result = 0; byte[] data = readBuffer(size); for (int i = 0; i < size; i++) { result = result * 256; result = (data[size - 1 - i] & 0x000000FF) + result; } return (short) result; } /** * Reads a 32-bits integer from the stream. The values are stored in little endian formats. * * @return An integer value stored in the stream. */ public int readInteger() { int size = 4; int result = 0; byte[] data = readBuffer(size); for (int i = 0; i < size; i++) { result = result * 256; result = (data[size - 1 - i] & 0x000000FF) + result; } return result; } /** * Reads a 64-bits integer from the stream. The values are stored in little endian formats. * * @return An integer value stored in the stream. */ public long readLongInteger() { int size = 8; long result = 0; byte[] data = readBuffer(size); for (int i = 0; i < size; i++) { result = result * 256; result = (data[size - 1 - i] & 0x000000FF) + result; } return result; } /** * Reads a 32-bits floating point value from the stream. The values are stored in IEE 754 and * little endian formats. * * @return A float value stored in the stream. */ public float readFloat() { float result = Float.NaN; int hasValue = readByte(); if (hasValue == 1) { int temp = readInteger(); result = Float.intBitsToFloat(temp); } return result; } /** * Reads a 64-bits floating point value from the stream. The values are stored in IEE 754 and * little endian formats. * * @return A double value stored in the stream. */ public double readDouble() { double result = Double.NaN; int hasValue = readByte(); if (hasValue == 1) { long temp = readLongInteger(); result = Double.longBitsToDouble(temp); } return result; } /** * Reads a string with UTF-8 encoding from stream. * * @return The string stored in the stream, or null if it has no value. */ public String readString() { String result = null; int hasValue = readByte(); if (hasValue == 1) { int length = readInteger(); byte[] data = readBuffer(length); result = new String(data, StandardCharsets.UTF_8); } return result; } /** * Read a multidimensional numpy array from the stream. * * @return The numpy array stored in the stream, or null if it has no value. */ public NumpyArray readNumpyArray() { NumpyArray result = null; int hasValue = readByte(); if (hasValue == 1) { int[] shape = new int[readInteger()]; int elementType = readByte(); for (int i = 0; i < shape.length; i++) { shape[i] = readInteger(); } result = createNumpyArray(elementType, shape); readNumpyDataFromStream(result.getWrapper().getRawArray(), shape, 0, elementType); } return result; } /** * The element type of a numpy array is stored as a byte. The value of this byte is defined as * constants ELEMENT_TYPE_* in the class. This method converts these element type constants into * respective Java types to create an array using reflection. * * @param elementType A byte value read from buffer that specifies the type of numpy array. * @return A Class object used by reflection to create a new array. */ private NumpyArray createNumpyArray(int elementType, int[] shape) { NumpyArray result = null; if (elementType == ELEMENT_TYPE_BYTE || elementType == ELEMENT_TYPE_UNSIGNED_BYTE) { result = NumpyArrayFactory.arrayOfInt8WithShape(shape); } else if (elementType == ELEMENT_TYPE_SHORT || elementType == ELEMENT_TYPE_UNSIGNED_SHORT) { result = NumpyArrayFactory.arrayOfInt16WithShape(shape); } else if (elementType == ELEMENT_TYPE_INT || elementType == ELEMENT_TYPE_UNSIGNED_INT) { result = NumpyArrayFactory.arrayOfInt32WithShape(shape); } else if (elementType == ELEMENT_TYPE_LONG || elementType == ELEMENT_TYPE_UNSIGNED_LONG) { result = NumpyArrayFactory.arrayOfInt64WithShape(shape); } else if (elementType == ELEMENT_TYPE_FLOAT) { result = NumpyArrayFactory.arrayOfFloatWithShape(shape); } else if (elementType == ELEMENT_TYPE_DOUBLE) { result = NumpyArrayFactory.arrayOfDoubleWithShape(shape); } else { throw new ScikitLearnCoreException(String.format("Numpy array with element type %d is not supported.", elementType)); } return result; } /** * Reads a list from the stream. * * @return The list stored in the stream, or null if it has no value. */ public List<Object> readList() { List<Object> result = null; int hasValue = readByte(); if (hasValue == 1) { result = new ArrayList<>(); int count = readInteger(); for (int i = 0; i < count; i++) { byte elementType = readByte(); if (elementType == ELEMENT_TYPE_NULL) { result.add(null); } else { IBinaryModelPackagePrimitiveValueReader reader = getPrimitiveDataReader(elementType); Object value = reader.readPrimitiveValue(); result.add(value); } } } return result; } /** * Reads a dictionary from the stream. * * @return The dictionary stored in the stream, or null if it has no value. */ public Map<String, Object> readDictionary() { Map<String, Object> result = null; int hasValue = readByte(); if (hasValue == 1) { result = new HashMap<>(); int count = readInteger(); for (int i = 0; i < count; i++) { String key = readString(); byte elementType = readByte(); if (elementType == ELEMENT_TYPE_NULL) { result.put(key, null); } else if (elementType == ELEMENT_TYPE_STRING_ARRAY) { result.put(key, readStringArray()); } else { IBinaryModelPackagePrimitiveValueReader reader = getPrimitiveDataReader(elementType); Object value = reader.readPrimitiveValue(); result.put(key, value); } } } return result; } /** * Reads an array of string from the stream. * * @return The String[] stored in the stream, or null if it has no value. */ public String[] readStringArray() { String[] result = null; int hasValue = readByte(); if (hasValue == 1) { int count = readInteger(); result = new String[count]; for (int i = 0; i < count; i++) { result[i] = readString(); } } return result; } /** * Recursively read the stream to load an encoded numpy array from the stream. * * @param array The array to be loaded. * @param shape The shape of the numpy array. * @param dimension The current dimension being loaded. * @param elementType The type of the numpy array's elements. */ private void readNumpyDataFromStream(Object array, int[] shape, int dimension, int elementType) { if (dimension == shape.length - 1) { // This is the last dimension of the tensor, read actual values. IBinaryModelPackagePrimitiveValueReader reader = getPrimitiveDataReader(elementType); int count = shape[dimension]; for (int i = 0; i < count; i++) { Array.set(array, i, reader.readPrimitiveValue()); } } else { // This is an intermediate dimensions, it should read a tensor from the buffer for (int i = 0; i < shape[dimension]; i++) { readNumpyDataFromStream(Array.get(array, i), shape, dimension + 1, elementType); } } } /** * Gets an IBinaryModelPackagePrimitiveValueReader to read numerical values from the stream. This * method was added to prevent having many if-elses in the code. * * @param elementType A byte value read from buffer that specifies the type of numerical value. * @return An instance of IBinaryModelPackagePrimitiveValueReader to read numerical values. */ private IBinaryModelPackagePrimitiveValueReader getPrimitiveDataReader(int elementType) { IBinaryModelPackagePrimitiveValueReader result = null; if (elementType == ELEMENT_TYPE_BYTE || elementType == ELEMENT_TYPE_UNSIGNED_BYTE) { result = this::readByte; } else if (elementType == ELEMENT_TYPE_SHORT || elementType == ELEMENT_TYPE_UNSIGNED_SHORT) { result = this::readShort; } else if (elementType == ELEMENT_TYPE_INT || elementType == ELEMENT_TYPE_UNSIGNED_INT) { result = this::readInteger; } else if (elementType == ELEMENT_TYPE_LONG || elementType == ELEMENT_TYPE_UNSIGNED_LONG) { result = this::readLongInteger; } else if (elementType == ELEMENT_TYPE_FLOAT) { result = this::readFloat; } else if (elementType == ELEMENT_TYPE_DOUBLE) { result = this::readDouble; } else if (elementType == ELEMENT_TYPE_STRING) { result = this::readString; } else if (elementType == ELEMENT_TYPE_DICTIONARY) { result = this::readDictionary; } else if (elementType == ELEMENT_TYPE_NUMPY_ARRAY) { result = this::readNumpyArray; } else if (elementType == ELEMENT_TYPE_LIST) { result = this::readList; } else { throw new ScikitLearnCoreException(String.format("Numpy array with element type %d is not supported.", elementType)); } return result; } /** * Reads a buffer from the stream. * * @param size Length of the buffer to be read from stream. * @return A byte[] buffer. */ private byte[] readBuffer(int size) { byte[] buffer = new byte[size]; int length = 0; try { length = stream.read(buffer); } catch (IOException e) { throw new ScikitLearnCoreException("Unable to read from buffer."); } if (length != size) { throw new ScikitLearnCoreException(String.format("Unable to read %d bytes from the stream.", size)); } return buffer; } /** * Checks if there is still available content in the input stream. * * @return A boolean indicating if the stream still has content or not. */ public boolean canRead() { try { return stream.available() > 0; } catch (IOException e) { throw new ScikitLearnCoreException("An error occurred while assessing if the stream reached end or not:\n" + e.getMessage()); } } } /** * An abstraction on the methods that can read a primitive value from the stream. */ interface IBinaryModelPackagePrimitiveValueReader { /** * Reads a primitive value from the stream. * * @return The primitive value read from stream. */ Object readPrimitiveValue(); }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/packaging/IScikitLearnPackage.java
package ai.sklearn4j.core.packaging; import java.util.Map; /** * This interface provides an abstraction over the physical file format to decouple the deserialization * logic from the file format. This will ease the modifications to the file format and versioning for * backward compatibility. */ public interface IScikitLearnPackage { /** * Gets the object that stores the information provided in the binary package file header. The header * include at the minimum the version of the file and the version of scikit-learn used to train the * content of the file. * * @return An instance of IScikitLearnPackageHeader containing the parsed information of the file header. */ IScikitLearnPackageHeader getPackageHeader(); /** * Gets a Map[String: Object] of the extra values stored by the developer when saving the binary package. * * @return A dictionary that contains the extra values stored along with the binary package file. */ Map<String, Object> getExtraValues(); /** * Get the primary content stored in binary package file. * * @param name Name of the content to retrieve. * @return A scikit-learn object that can now be used in Java. */ Object getModel(String name); /** * Loads the binary package from a file. * * @param path Path of file to be loaded. */ void loadFromFile(String path); }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/packaging/IScikitLearnPackageHeader.java
package ai.sklearn4j.core.packaging; /** * Abstracts the version of the binary package from its physical layout and its version. */ public interface IScikitLearnPackageHeader { /** * Gets the version of the binary package file. * * @return An int value specifying the version. */ int getFileFormatVersion(); /** * Gets the version that was used to train the scikit-learn object. * * @return A string version of scikit-learn library. */ String getScikitLearnVersion(); }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/packaging/ScikitLearnPackageFactory.java
package ai.sklearn4j.core.packaging; import ai.sklearn4j.core.ScikitLearnCoreException; import ai.sklearn4j.core.packaging.version_1.ScikitLearnPackageV1; import java.io.FileInputStream; /** * ScikitLearnPackageFactory is a factory that takes in the physical file (or stream) of a binary package * and parse it into a ready to use object. It also supports handling different versions of the binary * files. */ public class ScikitLearnPackageFactory { /** * Load a binary package file into a ready to use object. It reads the version of the file and * load the appropriate loader to deserialize the file. * * @param path Path of the file to be loaded. * @return An IScikitLearnPackage object that represent the models stored in the binary package file. */ public static IScikitLearnPackage loadFromFile(String path) { int version = readFileVersion(path); IScikitLearnPackage pkg = null; if (version == 1) { pkg = new ScikitLearnPackageV1(); pkg.loadFromFile(path); } else { throw new ScikitLearnCoreException("This version of the file format is not supported."); } return pkg; } /** * Reads the version of the binary package from a file. * * @param path Path of the file to be loaded. * @return An integer representing the file format version. */ private static int readFileVersion(String path) { try { FileInputStream fs = new FileInputStream(path); BinaryModelPackage buffer = BinaryModelPackage.fromStream(fs); int result = buffer.readInteger(); fs.close(); return result; } catch (Exception ex) { throw new ScikitLearnCoreException("An error occurred while determining the version of binary package file." + ex.getMessage()); } } }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/packaging
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/packaging/loaders/BaseScikitLearnContentLoader.java
package ai.sklearn4j.core.packaging.loaders; import ai.sklearn4j.base.ClassifierMixin; import ai.sklearn4j.core.ScikitLearnCoreException; import ai.sklearn4j.core.libraries.numpy.NumpyArray; import ai.sklearn4j.core.packaging.BinaryModelPackage; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; /** * A base class that implements common functionality shred among the scikit-learn object * loaders. Each loader will provide a list of supported fields to BaseScikitLearnContentLoader * instead of implementing the deserialization manually to simplify the loaders as much as * possible. * * @param <ObjectType> The type of the scikit-learn object that the loader supports. */ public abstract class BaseScikitLearnContentLoader<ObjectType> implements IScikitLearnContentLoader { /** * The type name of the loader. */ private final String typeName; /** * A map of the fields the loader requires to load an object. */ private final Map<String, LoaderFieldInfo> fields = new HashMap<>(); /** * Instantiate a BaseScikitLearnContentLoader object. * * @param typeName The type name of the loader. */ protected BaseScikitLearnContentLoader(String typeName) { this.typeName = typeName; registerSetters(); if (createResultObject() instanceof ClassifierMixin) { registerLongField("n_features", this::setNumberOfFeatureIn); registerStringArrayField("feature_names", this::setFeaturesIn); } } /** * An abstract method to initialize a new instance of the scikit-learn object supported * by the loader. * * @return The unloaded scikit-learn object supported by the loader. */ protected abstract ObjectType createResultObject(); /** * An abstract method implemented by the derived classes that loads the layout of the * binary format. BaseScikitLearnContentLoader uses this layout to load the object. */ protected abstract void registerSetters(); /** * Name of the loader. The name is stored in the header of the binary package file to be used during * deserialization. * * @return The name/id of the loader type. */ @Override public String getTypeName() { return this.typeName; } /** * Loads the scikit-learn object with the provided layout in registerSetters. * * @param buffer The buffer to load the object from. * @return The fully initialized scikit-learn object. */ @Override public Object loadContent(BinaryModelPackage buffer) { ObjectType result = createResultObject(); int fieldCount = buffer.readInteger(); for (int i = 0; i < fieldCount; i++) { String name = buffer.readString(); if (!fields.containsKey(name)) { throw new ScikitLearnCoreException("Package contains an unregistered field name: " + name); } LoaderFieldInfo info = fields.get(name); if (info.fieldType == LoaderFieldInfo.FIELD_TYPE_DOUBLE) { double value = buffer.readDouble(); ((IScikitLearnLoaderDoubleFieldSetter<ObjectType>) info.setter).setDoubleField(result, value); } else if (info.fieldType == LoaderFieldInfo.FIELD_TYPE_LONG) { long value = buffer.readLongInteger(); ((IScikitLearnLoaderLongFieldSetter<ObjectType>) info.setter).setLongField(result, value); } else if (info.fieldType == LoaderFieldInfo.FIELD_TYPE_STRING) { String value = buffer.readString(); ((IScikitLearnLoaderStringFieldSetter<ObjectType>) info.setter).setStringField(result, value); } else if (info.fieldType == LoaderFieldInfo.FIELD_TYPE_NUMPY) { NumpyArray value = buffer.readNumpyArray(); ((IScikitLearnLoaderNumpyArrayFieldSetter<ObjectType>) info.setter).setNumpyArrayField(result, value); } else if (info.fieldType == LoaderFieldInfo.FIELD_TYPE_STRING_ARRAY) { String[] value = buffer.readStringArray(); ((IScikitLearnLoaderStringArrayFieldSetter<ObjectType>) info.setter).setStringArrayField(result, value); } else if (info.fieldType == LoaderFieldInfo.FIELD_TYPE_LIST) { List<Object> value = buffer.readList(); ((IScikitLearnLoaderListFieldSetter<ObjectType>) info.setter).setListField(result, value); } else if (info.fieldType == LoaderFieldInfo.FIELD_TYPE_DICTIONARY) { Map<String, Object> value = buffer.readDictionary(); ((IScikitLearnLoaderDictionaryFieldSetter<ObjectType>) info.setter).setDictionaryField(result, value); } else if (info.fieldType == LoaderFieldInfo.FIELD_TYPE_LIST_OF_NUMPY_ARRAY) { List<Object> value = buffer.readList(); List<NumpyArray> finalValue = new ArrayList<>(); for (Object o : value) { finalValue.add((NumpyArray) o); } ((IScikitLearnLoaderListOfNumpyArrayFieldSetter) info.setter).setListOfNumpyArrayField(result, finalValue); } } return result; } /** * Registers a double field for the scikit-learn serialized layout. * * @param name Name of the field. * @param setter The setter callback to load the value of the scikit-learn object. */ protected void registerDoubleField(String name, IScikitLearnLoaderDoubleFieldSetter<ObjectType> setter) { if (fields.containsKey(name)) { throw new ScikitLearnCoreException("Field is already added"); } LoaderFieldInfo field = new LoaderFieldInfo(); field.name = name; field.setter = setter; field.fieldType = LoaderFieldInfo.FIELD_TYPE_DOUBLE; fields.put(name, field); } /** * Registers a long integer field for the scikit-learn serialized layout. * * @param name Name of the field. * @param setter The setter callback to load the value of the scikit-learn object. */ protected void registerLongField(String name, IScikitLearnLoaderLongFieldSetter<ObjectType> setter) { if (fields.containsKey(name)) { throw new ScikitLearnCoreException("Field is already added"); } LoaderFieldInfo field = new LoaderFieldInfo(); field.name = name; field.setter = setter; field.fieldType = LoaderFieldInfo.FIELD_TYPE_LONG; fields.put(name, field); } /** * Registers a string field for the scikit-learn serialized layout. * * @param name Name of the field. * @param setter The setter callback to load the value of the scikit-learn object. */ protected void registerStringField(String name, IScikitLearnLoaderStringFieldSetter<ObjectType> setter) { if (fields.containsKey(name)) { throw new ScikitLearnCoreException("Field is already added"); } LoaderFieldInfo field = new LoaderFieldInfo(); field.name = name; field.setter = setter; field.fieldType = LoaderFieldInfo.FIELD_TYPE_STRING; fields.put(name, field); } /** * Registers a numpy array field for the scikit-learn serialized layout. * * @param name Name of the field. * @param setter The setter callback to load the value of the scikit-learn object. */ protected void registerNumpyArrayField(String name, IScikitLearnLoaderNumpyArrayFieldSetter<ObjectType> setter) { if (fields.containsKey(name)) { throw new ScikitLearnCoreException("Field is already added"); } LoaderFieldInfo field = new LoaderFieldInfo(); field.name = name; field.setter = setter; field.fieldType = LoaderFieldInfo.FIELD_TYPE_NUMPY; fields.put(name, field); } /** * Registers a String array field for the scikit-learn serialized layout. * * @param name Name of the field. * @param setter The setter callback to load the value of the scikit-learn object. */ protected void registerStringArrayField(String name, IScikitLearnLoaderStringArrayFieldSetter<ObjectType> setter) { if (fields.containsKey(name)) { throw new ScikitLearnCoreException("Field is already added"); } LoaderFieldInfo field = new LoaderFieldInfo(); field.name = name; field.setter = setter; field.fieldType = LoaderFieldInfo.FIELD_TYPE_STRING_ARRAY; fields.put(name, field); } /** * Registers a list of numpy array field for the scikit-learn serialized layout. * * @param name Name of the field. * @param setter The setter callback to load the value of the scikit-learn object. */ protected <ArrayType> void registerListOfNumpyArrayField(String name, IScikitLearnLoaderListOfNumpyArrayFieldSetter<ObjectType, ArrayType> setter) { if (fields.containsKey(name)) { throw new ScikitLearnCoreException("Field is already added"); } LoaderFieldInfo field = new LoaderFieldInfo(); field.name = name; field.setter = setter; field.fieldType = LoaderFieldInfo.FIELD_TYPE_LIST_OF_NUMPY_ARRAY; fields.put(name, field); } /** * Registers a list field for the scikit-learn serialized layout. * * @param name Name of the field. * @param setter The setter callback to load the value of the scikit-learn object. */ protected void registerListField(String name, IScikitLearnLoaderListFieldSetter<ObjectType> setter) { if (fields.containsKey(name)) { throw new ScikitLearnCoreException("Field is already added"); } LoaderFieldInfo field = new LoaderFieldInfo(); field.name = name; field.setter = setter; field.fieldType = LoaderFieldInfo.FIELD_TYPE_LIST; fields.put(name, field); } /** * Registers a dictionary field for the scikit-learn serialized layout. * * @param name Name of the field. * @param setter The setter callback to load the value of the scikit-learn object. */ protected void registerDictionaryField(String name, IScikitLearnLoaderDictionaryFieldSetter<ObjectType> setter) { if (fields.containsKey(name)) { throw new ScikitLearnCoreException("Field is already added"); } LoaderFieldInfo field = new LoaderFieldInfo(); field.name = name; field.setter = setter; field.fieldType = LoaderFieldInfo.FIELD_TYPE_DICTIONARY; fields.put(name, field); } /** * Sets the list of features names' of the dataset the model was trained on. * * @param result The classifier to be loaded. * @param value The list of feature names. */ private void setFeaturesIn(ObjectType result, String[] value) { if (result instanceof ClassifierMixin) { ((ClassifierMixin) result).setFeatureNamesIn(value); } } /** * Sets the number of features of the dataset the model was trained on. * * @param result The classifier to be loaded. * @param value The number of features. */ private void setNumberOfFeatureIn(ObjectType result, long value) { if (result instanceof ClassifierMixin) { ((ClassifierMixin) result).setNumberOfFeatures((int) value); } } } /** * Data class to store the information on how to load a field. */ class LoaderFieldInfo { /** * Constant to specify the field is of type double. */ public static final int FIELD_TYPE_DOUBLE = 1; /** * Constant to specify the field is of type long. */ public static final int FIELD_TYPE_LONG = 2; /** * Constant to specify the field is of type numpy array. */ public static final int FIELD_TYPE_NUMPY = 3; /** * Constant to specify the field is of type string array. */ public static final int FIELD_TYPE_STRING_ARRAY = 4; /** * Constant to specify the field is of type list of numpy array. */ public static final int FIELD_TYPE_LIST_OF_NUMPY_ARRAY = 5; /** * Constant to specify the field is of type list. */ public static final int FIELD_TYPE_LIST = 6; /** * Constant to specify the field is of type String. */ public static final int FIELD_TYPE_STRING = 7; /** * Constant to specify the field is of type dictionary. */ public static final int FIELD_TYPE_DICTIONARY = 8; /** * The name of the field. */ public String name = null; /** * The type of the field. */ public int fieldType = 0; /** * The setting method that sets the loaded value in the classifier. */ public Object setter = null; }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/packaging
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/packaging/loaders/IScikitLearnContentLoader.java
package ai.sklearn4j.core.packaging.loaders; import ai.sklearn4j.core.packaging.BinaryModelPackage; /** * IScikitLearnContentLoader abstracts the format of individual objects from the file formatting. A class * should be derived from this interface for each classifier in scikit-learn. */ public interface IScikitLearnContentLoader { /** * Name of the loader. The name is stored in the header of the binary package file to be used during * deserialization. * * @return The name/id of the loader type. */ String getTypeName(); /** * Loads a scikit-learn object from an input stream. * * @param buffer The buffer to load the object from. * @return A deserialized ready to use object. */ Object loadContent(BinaryModelPackage buffer); /** * Creates a clone of the instance. * * @return An empty clean instance of the loader. */ IScikitLearnContentLoader duplicate(); }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/packaging
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/packaging/loaders/IScikitLearnLoaderDictionaryFieldSetter.java
package ai.sklearn4j.core.packaging.loaders; import java.util.Map; /** * A container for a method that sets a dictionary value into a scikit-learn object during deserialization. * * @param <ObjectType> The type of the scikit-learn object. */ public interface IScikitLearnLoaderDictionaryFieldSetter<ObjectType> { /** * Sets a dictionary value into a scikit-learn object. * * @param obj The scikit-learn object. * @param value The value to be set. */ void setDictionaryField(ObjectType obj, Map<String, Object> value); }
0
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/packaging
java-sources/ai/scikitlearn4x/sklearn4jvm/0.0.4/ai/sklearn4j/core/packaging/loaders/IScikitLearnLoaderDoubleFieldSetter.java
package ai.sklearn4j.core.packaging.loaders; /** * A container for a method that sets a double value into a scikit-learn object during deserialization. * * @param <ObjectType> The type of the scikit-learn object. */ public interface IScikitLearnLoaderDoubleFieldSetter<ObjectType> { /** * Sets a double value into a scikit-learn object. * * @param obj The scikit-learn object. * @param value The value to be set. */ void setDoubleField(ObjectType obj, double value); }