我正在使用ubuntu 14.04.我想安装CUDA.但我不知道哪个版本对我的笔记本电脑有好处.我跟踪我的驱动器
$cat /proc/driver/nvidia/version
NVRM version: NVIDIA UNIX x86_64 Kernel Module 304.125 Mon Dec 1 19:58:28 PST 2014
GCC version: gcc version 4.8.2 (Ubuntu 4.8.2-19ubuntu1)
Run Code Online (Sandbox Code Playgroud)
我尝试安装CUDA,cuda-linux64-rel-7.0.28-19326674但是当我按命令测试时
./deviceQuery
./deviceQuery Starting...
CUDA Device Query (Runtime API) version (CUDART static linking)
cudaGetDeviceCount returned 35
-> CUDA driver version is insufficient for CUDA runtime version
Result = FAIL
Run Code Online (Sandbox Code Playgroud)
你能帮我解决这个问题吗?我很多次重新安装我的ubuntu.非常感谢
我希望在Android 5.0中使用我的手机的应答电话GUI(手机的GUI)来接听来电.我找到了一种方法,需要进行一项活动,用于发送一些动作来打开Phone的GUI.我成功打开了电话的GUI来接听来电.问题是如何打开手机GUI的扬声器.我尝试了代码,但它没有打开.你能帮我解决Android L中的那个问题吗?
audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
audioManager.setMode(AudioManager.MODE_IN_CALL);
if (!audioManager.isSpeakerphoneOn())
audioManager.setSpeakerphoneOn(true);
audioManager.setMode(AudioManager.MODE_NORMAL);
Run Code Online (Sandbox Code Playgroud)
表现
<uses-permission android:name="android.permission.CALL_PHONE"/>
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.MODIFY_PHONE_STATE" />
Run Code Online (Sandbox Code Playgroud)
此外,我们是否有更多的射击方式打开接听来电使用接听电话的意图.我的方式很长,因为它使用了一个Activity.
这是我的全班代码
public class AcceptCallActivity extends Activity {
private static final String MANUFACTURER_HTC = "HTC";
private KeyguardManager keyguardManager;
private AudioManager audioManager;
private CallStateReceiver callStateReceiver;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
keyguardManager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
}
@Override
protected void onResume() {
super.onResume();
registerCallStateReceiver();
updateWindowFlags();
acceptCall();
}
@Override
protected void onPause() {
super.onPause();
if (callStateReceiver …Run Code Online (Sandbox Code Playgroud) 我有一个Android应用程序,用于连接蓝牙低功耗(BLE)和我的手机.该应用程序在Galaxy S5(Android 5.0.1),Galaxy S6(Android 6.0)等近乎手机中运行良好.但是,它在Galaxy Note 3(Android 5.0.1)中存在一个关键问题.
当我调用该connect()函数,然后调用readCharacteristic()它时,它返回错误:
onClientConnectionState() - status = 22 clientIf = 7
我调用connect函数约2秒后发生错误.我查找了一些解决方案,比如在通话前做出延迟 readCharacteristic(),但是无法解决.
你能解决我的问题吗?
谢谢大家.
这是我的代码:
private final BluetoothGattCallback mGattCallback = new BluetoothGattCallback() {
@Override
public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) {
if (newState == BluetoothProfile.STATE_CONNECTED) {
mBluetoothGatt.discoverServices();
} else if (newState == BluetoothProfile.STATE_DISCONNECTED) {}
}
@Override
public void onServicesDiscovered(BluetoothGatt gatt, int status) {
if (status == BluetoothGatt.GATT_SUCCESS) {
try {
Thread.sleep(500);
readCharacteristic(); …Run Code Online (Sandbox Code Playgroud) 在我的项目代码中,我发现有人在代码中使用了#ifdefand 。#if我想知道使用它们的目的是什么?据我所知,它告诉预处理器不会在该代码内执行任何操作。下面的代码给出了两个使用它们的示例。我试图找到TEST_PURPOSE(真/假)的定义,但找不到。从下面的代码中,如何在里面做一些事情#ifdef TEST_PURPOSE?我使用的是视觉工作室2012
#ifdef TEST_PURPOSE
int i=1;
printf("Something %d,"i);
#endif
#if 0
int i=1;
printf("Something %d,"i);
#endif
Run Code Online (Sandbox Code Playgroud) 我的目标是在蓝牙低功耗设备和手机之间建立自动连接.我按照示例代码找到了该行
// We want to directly connect to the device, so we are setting the autoConnect parameter to false.
mBluetoothGatt = device.connectGatt(this, false, mGattCallback);
Run Code Online (Sandbox Code Playgroud)
上面的代码表示false用于自动连接.但是,我在这里找到了API ,它说
BluetoothGatt connectGatt(上下文上下文,布尔autoConnect,BluetoothGattCallback回调,int传输)连接到此设备托管的GATT服务器.
我还尝试了两个标志:true而且false,只有true工作.我使用的是版本> = Android 5.0.代码和API之间有什么不一致吗?哪个标志是正确的?如果我想进行自动连接,是否需要注意?
这是我的代码
public boolean connect(final String address) {
if (mBluetoothAdapter == null || address == null) {
Log.w(TAG, "BluetoothAdapter not initialized or unspecified address.");
return false;
}
// Previously connected device. Try to reconnect.
if (mBluetoothDeviceAddress != null && …Run Code Online (Sandbox Code Playgroud) 我使用的是Android 5.0.该版本提供SmartLock功能,允许通过连接可信设备来解锁密码/模式.我有一个蓝牙低功耗(BLE)设备,注册为可信设备.我想用BLE解锁(模式模式)手机.当BLE和手机连接并且事件可用数据时,它将解锁手机
if (BluetoothLeService.ACTION_DATA_AVAILABLE.equals(action))
// Calling unlock by the SmartLock API
Run Code Online (Sandbox Code Playgroud)
android bluetooth bluetooth-lowenergy android-bluetooth google-smartlockpasswords
我写了一个递归函数,然而,它需要花费很多时间.因此我对它进行了矢量化,但它不会产生与递归函数相同的结果.这是我的非矢量化代码:
function visited = procedure_explore( u, adj_mat, visited )
visited(u) = 1;
neighbours = find(adj_mat(u,:));
for ii = 1:length(neighbours)
if (visited(neighbours(ii)) == 0)
visited = procedure_explore( neighbours(ii), adj_mat, visited );
end
end
end
Run Code Online (Sandbox Code Playgroud)
这是我的矢量化代码:
function visited = procedure_explore_vec( u, adj_mat, visited )
visited(u) = 1;
neighbours = find(adj_mat(u,:));
len_neighbours=length(neighbours);
visited_neighbours_zero=visited(neighbours(1:len_neighbours)) == 0;
if(~isempty(visited_neighbours_zero))
visited = procedure_explore_vec( neighbours(visited_neighbours_zero), adj_mat, visited );
end
end
Run Code Online (Sandbox Code Playgroud)
这是测试代码
function main
adj_mat=[0 0 0 0;
1 0 1 1;
1 0 0 0;
1 0 0 …Run Code Online (Sandbox Code Playgroud) 我想获得Android L中的所有默认应用程序.我使用了下面的代码,但它们给了我一个错误的解决方案.让我们先看看我的代码
private void getMyAppLauncherDefault() {
final IntentFilter filter = new IntentFilter(Intent.ACTION_MAIN);
filter.addCategory(Intent.CATEGORY_HOME);
List<IntentFilter> filters = new ArrayList<IntentFilter>();
filters.add(filter);
List<ComponentName> activities = new ArrayList<ComponentName>();
final PackageManager packageManager = (PackageManager) getPackageManager();
packageManager.getPreferredActivities(filters, activities, null);
for (ComponentName activity : activities) {
Log.d(TAG,"======packet default:==="+activity.getPackageName());
}
}
Run Code Online (Sandbox Code Playgroud)
这是日志.日志显示com.google.android.googlequicksearchbox和之间的错误结果com.vlingo.midas.它们都是语音应用程序,但我将其设置com.google.android.googlequicksearchbox为默认值.我不知道为什么日志显示com.vlingo.midas.我该如何解决?谢谢
16:02:44.817 /com.exam D/Sample: ======packet default:===com.sec.android.gallery3d
16:02:44.827 /com.exam D/Sample: ======packet default:===com.android.mms
16:02:44.827 /com.exam D/Sample: ======packet default:===com.android.mms
16:02:44.827 /com.exam D/Sample: ======packet default:===com.vlingo.midas
16:02:44.827 /com.exam D/Sample: ======packet default:===com.sec.android.app.sbrowser
16:02:44.827 /com.exam D/Sample: …Run Code Online (Sandbox Code Playgroud) android android-intent android-package-managers android-5.0-lollipop
我正在制作一个使用蓝牙连接的应用程序.我打电话蓝牙连接onCreate()和关闭它onDestroy()的MainActivity:
// Bluetooth
private Bluetooth bt;
private boolean registered = false;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
bt = new Bluetooth(this);
bt.enableBluetooth();
bt.setCommunicationCallback(this);
bt.connectToName(bt.getBluetoothDevice(this));
IntentFilter filter = new IntentFilter(BluetoothAdapter.ACTION_STATE_CHANGED);
registerReceiver(mReceiver, filter);
registered = true;
}
@Override
public void onDestroy() {
super.onDestroy();
if(registered) {
unregisterReceiver(mReceiver);
registered=false;
}
bt.removeCommunicationCallback();
bt.disconnect();
if (handler != null && runnable != null) {
handler.removeCallbacks(runnable);
}
}
Run Code Online (Sandbox Code Playgroud)
该应用程序还支持LANDSCAPE和PORTRAIT模式(使用两种不同的布局).当屏幕旋转时,由于布局不同,MainActivity调用onCreate()和onDestroy功能.出于这个原因,我收到以下错误:
@@@ ABORTING: INVALID HEAP ADDRESS …Run Code Online (Sandbox Code Playgroud) sockets android bluetooth android-activity android-bluetooth
我有一个线性方程,如
Ax=b
Run Code Online (Sandbox Code Playgroud)
其中A是满级矩阵,其大小是512x512.b是一个矢量512x1.x是未知的矢量.我想找到x,因此,我有一些选择这样做
1.使用正常的方式
inv(A)*b
Run Code Online (Sandbox Code Playgroud)
2.使用SVD(奇异值分解)
[U S V]=svd(A);
x = V*(diag(diag(S).^-1)*(U.'*b))
Run Code Online (Sandbox Code Playgroud)
两种方法都给出了相同的结果.那么,使用SVD解决的好处是什么Ax=b,特别是在A2D矩阵的情况下呢?