我有一个尺寸如下的数组:
pos = np.array([[ 1.72, 2.56],
[ 0.24, 5.67],
[ -1.24, 5.45],
[ -3.17, -0.23],
[ 1.17, -1.23],
[ 1.12, 1.08]])
我希望找到数组每一行与索引点之间的距离
ref = np.array([1.22, 1.18])
因此我会有一个包含4个元素的数组作为答案,但我真的很困惑,因为我尝试了很多方法但是我们已经尝试了很多方法来解决这个问题。一个挑战。谢谢你的帮助。
预期答案是一个包含6个元素的数组。元素大致是:
[ 1.468, 4.596, 4.928 , 4.611, 2.410, 0.141 ]
答案 0 :(得分:0)
使用apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion 'android-P'
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "com.xxxxxxx.xx"
minSdkVersion 18
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
debuggable false
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'org.jetbrains.anko:anko-commons:0.10.4'
implementation 'androidx.core:core-ktx:1.0.0-alpha1'
implementation "androidx.appcompat:appcompat:1.0.0-alpha1"
implementation "androidx.legacy:legacy-support-v4:1.0.0-alpha1"
implementation 'androidx.constraintlayout:constraintlayout:1.1.0'
implementation "com.google.android.material:material:1.0.0-alpha1"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0-alpha1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha1'
implementation 'com.squareup.okhttp3:okhttp:3.10.0'
implementation 'com.google.code.gson:gson:2.8.2'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.7.0'
//firebase massaging
implementation 'com.google.firebase:firebase-messaging:15.0.2'
implementation 'com.google.firebase:firebase-core:15.0.2'
def lifecycle_version = "2.0.0-alpha1"
def room_version = "2.0.0-alpha1"
// ViewModel and LiveData
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
// room database persistent
implementation "androidx.room:room-runtime:$room_version"
kapt "androidx.room:room-compiler:$room_version"
// optional - Test helpers for LiveData
testImplementation "androidx.arch.core:core-testing:$lifecycle_version"
//data binding
//kapt 'com.android.databinding:compiler:3.1.2'
}
apply plugin: 'com.google.gms.google-services'
并假设欧几里德指标:
numpy
如果您需要Python列表(而不是import numpy as np
np.linalg.norm(pos - ref, axis=1)
数组),请将numpy
添加到上一行:
.tolist()